error using save name is not available

10 次查看(过去 30 天)
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 个评论
Rik
Rik 2018-6-4
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 2018-6-4
That is a very indirect and inefficient way to write data to a file. Just use fprintf.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2018-6-4
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)

类别

Help CenterFile Exchange 中查找有关 Variables 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by