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

16 ビュー (過去 30 日間)
Daivaraj P
Daivaraj P 2014 年 1 月 24 日
編集済み: Stephen23 2018 年 8 月 3 日
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 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLanguage Support についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by