Dear everyone,(adsbygoogle = window.adsbygoogle || []).push({});

i am trying to put my matrix result from my function 'matrix(1:20,1:5,'matrix.txt') in a text file like

y

x 1 2 3 4 5

1 3.33 4.34 23.21 23.12 0.00

2 2.42 2.42 13.42 34.52 2.23

until x=20,y=5

This code case many error:(, i try to search the similar code in google but it looks like mind. How can i output my matrix result into a text file?Code (Text):fid = fopen('file_name','w');

fprintf(fid,'\n y\n');

fprintf(fid,'\n x 1 2 3 4 5\n');

for j=1:length(x);

fprintf(fid,'%3d %s\t%20.2f %s\t%20.2f %s\t%20.2f\n %s\t%20.2f %s\t%20.2f',x,1,2,3,4,5);

end

fclose(fid);

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab beginner fprintf into .txt

Loading...

Similar Threads for Matlab beginner fprintf |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB Matlab data into bins |

**Physics Forums | Science Articles, Homework Help, Discussion**