save a fprintf as text data

조회 수: 4 (최근 30일)
Niklas Reinshagen
Niklas Reinshagen 2020년 5월 24일
답변: Srivardhan Gadila 2020년 5월 30일
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?

답변 (1개)

Srivardhan Gadila
Srivardhan Gadila 2020년 5월 30일
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);

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by