error using save name is not available

9 vues (au cours des 30 derniers jours)
Gonçalo Cordeiro
Gonçalo Cordeiro le 4 Juin 2018
In this code :
%%Part2: Results Construction
createOutputVideo(dataFolderName);
results = "";
for i = 1 : 1 : length(BBArray)
results = results + sprintf('%.0f\t' , BBArray(i, :)) + '\n';
results + sprintf('%.0f\t' , BBArray(i, :)) + '\n';
end
results;
save('result.txt',results,'delimiter','\t');
I have this error:
Error using save
'0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0
0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0
0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 \n0 0 0 0 .... is not a valid variable name.
I can i resolve ?
  2 commentaires
Rik
Rik le 4 Juin 2018
What is your goal? What are you trying to do? Do you want to write these values to a text file? Why not use the functions that actually do that, like dlmwrite, or fprintf?
Stephen23
Stephen23 le 4 Juin 2018
That is a very indirect and inefficient way to write data to a file. Just use fprintf.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 4 Juin 2018
save('result.txt', 'results', '-ascii', '-tabs');
I doubt this will be to your liking, but it is what you asked for.
I think you should instead
fid = fopen('result.txt', 'wt');
fwrite(fid, results);
fclose(fid)

Catégories

En savoir plus sur Variables dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by