error using save name is not available

9 ビュー (過去 30 日間)
Gonçalo Cordeiro
Gonçalo Cordeiro 2018 年 6 月 4 日
回答済み: Walter Roberson 2018 年 6 月 4 日
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 Center および File ExchangeVariables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by