fprint problem in matlab

3 visualizzazioni (ultimi 30 giorni)
Maria
Maria il 2 Giu 2020
Commentato: Star Strider il 2 Giu 2020
why the outstr value is 24 here ?

Risposte (1)

Star Strider
Star Strider il 2 Giu 2020
The fprintf fuction returns the number of bytes ouitput to the file.
You probably want sprintf instead here.
  2 Commenti
Maria
Maria il 2 Giu 2020
so the value it returns we wouudn't know unless we check somewhere?
Star Strider
Star Strider il 2 Giu 2020
In the code in your image of it (not the actual code, that I had to type in manually), the value is in ‘outstr’. It writes 24 bytes to the file, and the full string to your Command Window (the default output), returning 24 in ‘outstr’.
If you want it to return the actual string to your workspace, use:
outstr = sprintf('The answer is %s', data1);
That works. (I tested it.)

Accedi per commentare.

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by