How do I make my data that I'm trying to print out to a file be in a nice table fashion?
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    JoshT_student
 el 23 de Mayo de 2018
  
    
    
    
    
    Respondida: Walter Roberson
      
      
 el 23 de Mayo de 2018
            I have this code but it does not look good when I open it in notepad. I tried seeing if '\n' would fix it, but they did not. Is it because I'm using notepad to open the output100.dat file?
Code is below:
Thank you for your help
 for n=1:10
     t(n)=n;
     y1(n)=n^2/10
     y2(n)=n^3/100;
end 
fo=fopen('output100.dat','w');
%By printing the output to a file, one can edit the output
%suchas lining up column headings, etc. This cannot be
%done if one prints to the screen.
%Column headings
fprintf(fo, ' \n\nt      y1             y2              \n\n\n\n\n\n\n\n\n');
fprintf(fo, '--------------------------------------------------\n');
for n=1:10
    fprintf(fo, '%8.1f    %10.2f     %10.2f   \n',  t(n), y1(n), y2(n));
end
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 23 de Mayo de 2018
        For Notepad, change the 'w' to 'wt' on your fopen()
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Entering Commands 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!