- #1

- 47

- 0

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

Code:

```
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);
```