save a fprintf as text data

3 visualizzazioni (ultimi 30 giorni)
Niklas Reinshagen
Niklas Reinshagen il 24 Mag 2020
Risposto: Srivardhan Gadila il 30 Mag 2020
Hello, for my online class I should write a a line wich displays the Percentage of the Earth Layers. I choose the fprintf command and set the calculatet Percentage in it.
fprintf('\nPercentage of the EarthLayer:\nCore: %.1f%%\nMantle: %.1f%%\nCrust: %.1f%%\n\n',PercentCore,PercentMantle,PercentCrust)
Now I would like to save this as a .txt file. But when i type "save" and try to save it, it just saves a .txt file with the Number 74, I really don't get what i'm doing wrong...
Can anybody help me?

Risposte (1)

Srivardhan Gadila
Srivardhan Gadila il 30 Mag 2020
You can refer to fprintf documentation, it's Examples & fileID = fopen(filename,permission)
fileID = fopen('textFile.txt','w');
fprintf(fileID,'\nPercentage of the EarthLayer:\nCore: %.1f%%\nMantle: %.1f%%\nCrust: %.1f%%\n\n',PercentCore,PercentMantle,PercentCrust);
fclose(fileID);

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by