MATLAB Answers

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

29 views (last 30 days)
Daivaraj P
Daivaraj P on 24 Jan 2014
Edited: Stephen Cobeldick on 3 Aug 2018
a = 'Hello World';
fid = fopen('file_1.txt','w');
In the above program, instead of writing in .txt file I want to write in .html file.
Suggest me how to achieve this.


Sign in to comment.

Answers (1)

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

  1 Comment

Stephen Cobeldick
Stephen Cobeldick on 2 Aug 2018
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.

Sign in to comment.

Translated by