1 view (last 30 days)

I have a Matrix in Matlab Workspace having floating point data. The order of the matrix is 10x4. I want to write 1st row in A1 cell, 2nd row in A2 cell, 3rd row in A3 cell and so on into an Excel file using Matlab. How can I do that?

Regards,

Sadiq Akbar

xi
on 17 Oct 2019

use num2str() to convert your 10X4 numeric matrix into 10 strings.

Then use xlswrite() to write string into Excel cells.

Here's an example

filename='myfile.xlsx';

M=rand(10,4);

str=num2str(M);

for i=1:size(str,1)

xlswrite(filename, cellstr(str(i,:)), 'Sheet1', ['A',num2str(i)]);

end

xi
on 18 Oct 2019

Hi Sadiq,

I don't get what is the hard part that prevent you from realizing it?

Just make a judgement of whether it is swapped or not and then process it accordingly.

There are many ways you can choose to make such judgement: for example, you can do a pearson correlation between the estimated and the desired, for all the possible mutants upon swapping, and then choose the one with the hightest correlation score.

Xi

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://la.mathworks.com/matlabcentral/answers/485906-i-have-10-rows-and-four-columns-in-variable-two-i-want-to-write-one-row-in-one-cell-2nd-row-in-2nd#comment_757383

⋮## Direct link to this comment

https://la.mathworks.com/matlabcentral/answers/485906-i-have-10-rows-and-four-columns-in-variable-two-i-want-to-write-one-row-in-one-cell-2nd-row-in-2nd#comment_757383

Sign in to comment.