How i can reorder the sheets of excel in matlab to do a same sheet ?

6 ビュー (過去 30 日間)
Ana Soph
Ana Soph 2020 年 9 月 6 日
コメント済み: Image Analyst 2020 年 9 月 6 日
Hello, thank you so much for reading me, i have a question please.
How can reorder the sheets that i have in this program in matlab to do only a matrix with all the sheets? i want the original data of the archive named REN
clear;clc;
Cyears = 9;
Cdays = 31; % Enero
RAD = nan(Cdays, Cyears); % Average daily data: dia x año
for i=1:Cyears
RS = xlsread('REN',i);
RAD(:, i) = 600*sum(RS)'/1000000;
end
figure(1); imagesc(RAD); colorbar;
Thank you in advance ..
Best!!

採用された回答

KSSV
KSSV 2020 年 9 月 6 日
clear;clc;
Cyears = 9;
Cdays = 31; % Enero
iwant = zeros(144,31,9) ;
for i=1:Cyears
RS = xlsread('REN.xlsx',i);
iwant(:,:,i) = RS ;
end
  12 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 6 日
squeeze(mean(reshape(iwant, size(iwant,1)/6, 6, []), 2))
Ana Soph
Ana Soph 2020 年 9 月 6 日
thank you so much good man :D !

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 9 月 6 日
I'm not sure how the accepted answer does that. Maybe I didn't read closely enough. But if you want to do "only a matrix with all the sheets" in the workbook and not process any workbook where all the expected sheets are not there, then you can do this:
sheets = sheetnames('airlinesmall_subset.xlsx')
if length(sheets) == 13
% All sheets are present. We're expecting there to be 13 sheets in this workbook.
else
% All sheets are NOT present. Some are missing.
end
Now, to "reorder the sheets of excel" as you requested, there are two ways. You can either open the workbook using ActiveX (if using Windows) and then use ActiveX commands to put the sheets in whatever order you want, or you can call writecell() or writematrix() once per sheet in the desired order.
  5 件のコメント
Ana Soph
Ana Soph 2020 年 9 月 6 日
Awesome! , yes i have R2019a, so.. ok i will try this tool, thank you so much! :D
Image Analyst
Image Analyst 2020 年 9 月 6 日
Try this:
[~, sheetNames] = xlsfinfo('airlinesmall_subset.xlsx')
if length(sheetNames) == 13
% All sheets are present.
else
% All sheets are not present. Some are missing.
end
If you're skilled enough to use ActiveX, I'm attaching my ActiveX Excel utilities class. If you have Windows and ActiveX you can do literally anything that you'd do in Excel itself directly.
If I helped you maybe you could at least vote for my answer even though it wasn't your preferred answer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by