x*y 发帖数: 364 | 1 fprintf can save a file as you want, following is my example.
>>a=[1,2,3,4,5];
>>b=[2.0,4.0,6.0,8.0,10.0];
>> fid = fopen('test.dat','w')
fid =
3
>> for i=1:5
fprintf(fid,'%5d %2s %6.2f \n', a(i), ',', b(i));
end
>> fclose(fid)
ans =
0
>>
then test.dat is:
1 , 2.00
2 , 4.00
3 , 6.00
4 , 8.00
5 , 10.00
If you just want to use it in excel, you don't need comma actually, then it's
easier.
c=zeros(5,2);
c(1:5,1)=a';
c(1:5,2) =b';
save 'test.dat' c -ascii
T |
|