i have 300 sheets in one worksheet in excel. i wan to import this to matlab. I want to create loop where it reads all sheets and plot graph on a same graph.

조회 수: 2 (최근 30일)
[num,txt,raw] = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx');
Patients = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx','150','A7:A26'); %% X-axis constant for all plots
C1 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '150', 'D53:D72'); %% Cancer patients data Y axis of run number 150 (150 sheet name)
H1 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '150', 'E53:E72'); %%heart prob data y axis of run no 150 (150 sheet name)
L1 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '150', 'G7:G26'); %% Liver prob values
B1 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx' , '150', 'H7:H26); %% Bones values
K1 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '150' 'I7:I26'); %% Kidney values ..same for next sheet 151asfollows
C2 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '151', D53:D72'); next sheet in same workbook (151)
H2 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '151', E53:E72'); 151 Sheet no
L2 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '151', 'G7:G26');
B2 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '151', 'H7:H26');
K2 = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\medicaldatasheet.xlsx', '151', 'I7:I26'); same range goes for all the sheets in workbook.
plot(patients,C1)
hold on
plot(patients,C2)
hold off
plot(patients,H1)medicaldatasheet
hold on
plot(patients,H2)
plot(patients,B1)
hold on
plot(patients,B2)
hold off
plot(patients,L1)
hold on
plot(patients,L2)
hold off
plot(patients,K1)
hold on
plot(patients,K2)
hold off
I need all this 5 plots patients Vs C, CD vs patients Vs H, patients Vs B ,patients Vs L, patients Vs K just by mentioning the sheet numbers. for eg as mentioned above 150,151 sheets i want both the values of patients Vs C to be plotted in same graph so used hold on.
  댓글 수: 3
Rik
Rik 2022년 4월 23일
As I posted in my previous comment: if you disagree with my assessment, contact Mathworks support. I don't see anything that could be considered confidential. Can you explain which parts would be confidential? Can you think of any way to edit your question that would remove the confidential parts, but leave the essence of the question the same?
Shrutidat
Shrutidat 2022년 4월 24일
Yes sir now this editing is fine for me. can u pls do the same for the provided answer?

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

채택된 답변

VBBV
VBBV 2022년 4월 10일
편집: Jan 2022년 5월 20일
hold all
for I = 1:length(num)
A(:,I) = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\asd.xlsx',num2str(I),'A7:A26');
B(:,I) = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\asd.xlsx', num2str(I), 'D53:D72');
C(:,I) = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\asd.xlsx', num2str(I), 'E53:E72');
D(:,I) = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\asd.xlsx',num2str(I), 'G7:G26');
E(:,I) = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\asd.xlsx', num2str(I), 'H7:H26');
F(:,I) = xlsread('C:\Users\varun\OneDrive\Desktop\New folder\asd.xlsx', num2str(I), 'I7:I26');
figure(1)
plot(A(:,I),B(:,I)) % coefficient for all 300 sheets
figure(2)
plot(A(:,I),C(:,I)) % coefficient for all 300 sheets
figure(3)
plot(A(:,I),D(:,I)) %
figure(4)
plot(A(:,I),E(:,I))
figure(5)
plot(A(:,I),F(:,I))
end
  댓글 수: 4
Jan
Jan 2022년 5월 20일
@Shrutidat: You are aware that the original versions are still stored in the caches of the internet search engines?
Shrutidat
Shrutidat 2022년 5월 20일
Sir thank u so much 😭😭 And I'm really sorry for all the trouble 🥺

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by