Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

saving data to the file

1 vue (au cours des 30 derniers jours)
Artur Lipnicki
Artur Lipnicki le 10 Oct 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
How to use function fprintf in Matlab2016b? Why thoe following comands are uncorrect?
fid = fopen('file.txt','a');
fprintf(fid,'%.6f %.6f %.6f\n',xw,yw,rw);
fclose(fid);
  4 commentaires
Artur Lipnicki
Artur Lipnicki le 10 Oct 2016
Error using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.
José-Luis
José-Luis le 10 Oct 2016
What's the value of fid?
Do you have write access to the current folder?

Réponses (2)

Pritesh Shah
Pritesh Shah le 10 Oct 2016
Did you defined the variable xw,yw,rw?

Guillaume
Guillaume le 10 Oct 2016
Matlab failed to open the file. There may be many reasons for this, the file does not exist / the file is not is in the current directory (since you didn't specify a path) / you don't have read access to the file / something else.
Open the file with
[fid, errmsg] = fopen('file.txt', 'a');
assert(fid > 0, 'Failed to open file because: %s', errmsg);
And see what error you get.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by