Error using 'Save' including quotation marks around variables
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am running a piece of code that generates and plots two variables (Dmed and DSEM). The code has been used by my workplace for a long time, and it works well. I did not write it.
I want the raw numbers from the plot to save into a .csv file so I can run a separate analysis later looking at the individual numbers generated.
This is a loop that runs through selected data.
Every time I try to run it, it returns the same error:
Error using save
Must be a string scalar or character vector.
save([filename, '_output', '.csv'], 'Dmed', 'DSEM')
% I have also tried this without 'Dmed' and 'DSEM', where the variables are run like this:
save([filename, '_output'], Dmed, DSEM)
0 commentaires
Réponses (2)
madhan ravi
le 28 Juil 2020
Use writematrix() or dlmwrite() or csvwrite() for older versions bearing in mind that
filename = 'sample'; % for example
Steven Lord
le 29 Juil 2020
My guess is filename is a cell array containing a char row vector.
x = 1:10;
thefile = 'data571924.mat';
save(thefile, 'x') % works
thefile2 = {'data571924_cell.mat'};
save(thefile2, 'x') % fails
save(char(thefile2), 'x') % works
Many functions that can accept a char vector can also accept a cell array containing a char vector. save is not one of those many functions.
0 commentaires
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!