Borrar filtros
Borrar filtros

Writing data to a file

7 visualizaciones (últimos 30 días)
Millie Jones
Millie Jones el 26 de Mzo. de 2020
Comentada: Millie Jones el 28 de Mzo. de 2020
I'd like write 1 to 20 to a file, but not sure how I would go about finishing the code. I've attempted to use a for loop here and think this is the right approach as it does count from 1 to 20, but the end of my code looks like this...
And I'd like to remove the two ans, but have tried to put semi colons in different places to hide the ans and doesn't seem to work. Here is my (attempted) code:
fileid= fopen('data.dat','w')
for a = 1.0:1:20;

Respuesta aceptada

Bhaskar R
Bhaskar R el 26 de Mzo. de 2020
fileid= fopen('data.dat','w');
fprintf(fileid, '%d\n', [1:20]');
  1 comentario
Millie Jones
Millie Jones el 28 de Mzo. de 2020
Thank you :-) That makes a lot more sense, I realised I wasn't actually writing anything to my file

Iniciar sesión para comentar.

Más respuestas (0)


Más información sobre Low-Level File I/O en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by