Problem with array and save file?
1 回表示 (過去 30 日間)
古いコメントを表示
%% create
a = cell(10,5,3);
for participant = 1:10
for video = 1:5
a{participant,video,1} = participant ;
a{participant,video,2} = video ;
a{participant,video,3} = [
"Searching for Bobby Fischer",...
"D.O.A.",...
"The Hangover",...
"The Ring",...
"300",...
];
end
end
b = cell2table(num2cell(reshape( a, [10*5, 3])),...
'VariableNames', {'participant'; 'video'; 'video_name'});
writetable(b, 'load.xlsx', 'Sheet', 1);
I have some problem with my code above. I want to write a table like each video contain with each video_name like this
but my code for a table like this
How can i do to solve this problem? Can someone edit with my code? thank you
0 件のコメント
採用された回答
MarKf
2023 年 4 月 4 日
Do you need a 3D cell and then rehsape it or can you create it like the 2D table you want already?
videosn = ["Searching for Bobby Fischer",...
"D.O.A.",...
"The Hangover",...
"The Ring",...
"300"];
Nparticipants = 10; Nvideos = numel(videosn);
a = cell(Nparticipants*Nvideos,3);
for video = 1:Nvideos
for participant = 1:Nparticipants
idx = Nparticipants*(video-1)+participant;
a{idx,1} = participant;
a{idx,2} = video;
a{idx,3} = videosn(video);
end
end
b = cell2table(a,'VariableNames', {'participant'; 'video'; 'video_name'})
% writetable(b, 'load.xlsx', 'Sheet', 1);
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!