error using save name is not available

9 views (last 30 days)
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 Comments
Rik
Rik on 4 Jun 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 on 4 Jun 2018
That is a very indirect and inefficient way to write data to a file. Just use fprintf.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 4 Jun 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)

Categories

Find more on Variables in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!