Write nested cell array data into separate excel sheets

Hi all,
I have a nested array data (5 rows and 7 columns) and would like to save the results of each row onto separate excel sheets. In my case, I have 5 rows of nested cell data where I would like to have 5 excel sheets with sheet names representing the ID of the user.
Any help in this is highly appreciated. I have attached the data.

 채택된 답변

Arif Hoq
Arif Hoq 2022년 3월 18일
편집: Arif Hoq 2022년 3월 18일
try this:
A=load('Data3.mat');
B=A.Tc ;
firstrow=[B{1,:}];
% C=string(firstrow);
writecell(firstrow,'filename1.xlsx')
secrow=[B{2,:}];
writecell(secrow,'filename2.xlsx')
thirdrow=[B{3,:}];
writecell(thirdrow,'filename3.xlsx')
upto row 5....

댓글 수: 3

Hi Arif, thanks for your answer. Using your method, I can extract individual row data to seprate Excel files. I wanted these Excel files as one excel file with different sheets (in my case 5) and also would like to get it done automatically say using the loop etc. Because some instances I may end up 10 rows or more. First I will understand the logic and try to work it out. Any suggestions or modifications from your end is higlhly appreciated. Also, once I find the solution I will accept your answer.
I have figured out the answer. I am posting the detailed answer, Hope it is helpful to others.
If "Tc" is the nested cell array (refer to the Figure) then the following code creates separate Excel files for each nested row.
for i=1:numel(Tc(:,1))
Row= [Tc{i,:}]
writecell(Row,['filename' num2str(i) '.xlsx'])
end
great job..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

질문:

2022년 3월 18일

댓글:

2022년 3월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by