How can I write data from workspace in *.html file

a = 'Hello World';
fid = fopen('file_1.txt','w');
fprintf(fid,a);
fclose(fid);
In the above program, instead of writing in .txt file I want to write in .html file.
Suggest me how to achieve this.

답변 (1개)

Robert
Robert 2018년 8월 2일

0 개 추천

What's wrong with simply replacing .txt by .html?
a = 'Hello World';
fid = fopen('file_1.html','w');
fprintf(fid,a);
fclose(fid);
This works for me.

댓글 수: 1

Stephen23
Stephen23 2018년 8월 2일
편집: Stephen23 2018년 8월 3일
A text file containing only Hello World is not a valid HTML document according to the HTML5 specification. It is not clear if the original questioner just wanted a text file with the extension .html (not valid HTML, as this answer gives) or an actual valid HTML file. Check HTML file validity here:
"Smallest" valid HTML files are easy to find on the interweb.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

질문:

2014년 1월 24일

편집:

2018년 8월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by