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

21 visualizaciones (últimos 30 días)
Daivaraj P
Daivaraj P el 24 de En. de 2014
Editada: Stephen23 el 3 de Ag. de 2018
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.

Respuestas (1)

Robert
Robert el 2 de Ag. de 2018
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 comentario
Stephen23
Stephen23 el 2 de Ag. de 2018
Editada: Stephen23 el 3 de Ag. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Naming Conventions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by