Reputation: 55
I'm trying to save a 2 column matrix with a specific file name but I keep generating the same error message:
Error using save
Must be a string scalar or character vector
My code looks like this:
CustomName = ['TheDataFrom','_', animalname, '-', animalnumber,'-',num2str(stimNumber), num2str(stimType), '.mat']); % the name I want the file to have, changes with different specimens
TheData(:,1) = codes(index,1);
TheData(:,2) = times(values,1)); %both of these vectors are the same length
save(CustomName, TheData);
I have also tried making 'TheData' variable into a double vector by making TheData an empty matrix first, so the code looks like this with the extra line:
CustomName = ['TheDataFrom','_', animalname, '-', animalnumber,'-',num2str(stimNumber), num2str(stimType), '.mat']); % the name I want the file to have, changes with different specimens
TheData = zeros(length(index), 2) %make a matrix of the right number of rows and columns, comes out as class 'double'
TheData(:,1) = codes(index,1); %put data into each column
TheData(:,2) = times(values,1));
save(CustomName, TheData);
I just want to save this matrix with a specimen specific name, I am out of ideas for why what I'm doing is not working. Please help!
Thank you
Upvotes: 2
Views: 8097
Reputation: 6863
You need to specify the names of the variables you want to save as character vector, meaning that you do not want to actually pass the variable itself as argument of save
. Rather make a character vector that contains the name of the variable to store:
save(Customname, 'TheData');
Upvotes: 5