This is a part of my code.
a = 0;
for i = -3:3
for j = 1:10
a(j) = j^i;
end
xlswrite('out.xls', a','A1')
end
Here I am getting only the last value of a
in the out.xlx
file. But I want to fill the values of a
for each iteration of i
in consecutive columns of an Excel
file . Any suggestions ?
Update
I want output like this: -
1.0000 1.0000 1.0000 1 .....
0.1250 0.2500 0.5000 1 .....
0.0370 0.1111 0.3333 1 .....
0.0156 0.0625 0.2500 1 .....
0.0080 0.0400 0.2000 1 .....
0.0046 0.0278 0.1667 1 .....
0.0029 0.0204 0.1429 1 .....
0.0020 0.0156 0.1250 1 .....
0.0014 0.0123 0.1111 1 .....
0.0010 0.0100 0.1000 1 .....
and so on....
You are entering the value a in the cell A1. So it is taking only the last value of the array
a
. You need to give the entire range in order to input the complete array.Try something like this :
I hope it helps.
You have produced a 1D vector instead of a 2D matrix. This should work:
An even better solution would be to vectorize everything:
@EitanT, @HighPerformanceMark: Changed the answer to reflect your comment. I guess today is not my day - edited 4 times :)