Transpose multiple columns to one row

6 ビュー (過去 30 日間)
Luyi Huang
Luyi Huang 2022 年 3 月 23 日
編集済み: Matt J 2022 年 3 月 23 日
Hi there,
I have a file with 41 sheets and I'm trying to read data from column o from sheet1. Then I try to transpose that column into a row. And lastly I will repeat the above: reading column o again from sheet2 and transpose column o into the first row following the previous cells. I can't figure out how to add the transpose into my for loop, can anyone help with that?
Here is my code:
num_sheets = 41;
C = []
for i = 3:num_sheets
data = readmatrix('filename',i ,Range="O2:O57");
C = [C data(:,1)];
end
Thanks a lot!!

回答 (1 件)

Matt J
Matt J 2022 年 3 月 23 日
編集済み: Matt J 2022 年 3 月 23 日
num_sheets = 41;
C = cell(1,num_sheets);
for i = 3:num_sheets
C{i} = readmatrix('filename',i ,Range="O2:O57").';
end
C=cell2mat(C);

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by