error using save name is not available

10 visualizaciones (últimos 30 días)
Gonçalo Cordeiro
Gonçalo Cordeiro el 4 de Jun. de 2018
Respondida: Walter Roberson el 4 de Jun. de 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 comentarios
Rik
Rik el 4 de Jun. de 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 el 4 de Jun. de 2018
That is a very indirect and inefficient way to write data to a file. Just use fprintf.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 4 de Jun. de 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)

Categorías

Más información sobre Variables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by