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.

[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 Comments

Regarding your flag: nothing in your post or in the code in the answer is leaking any confidential information. There is nothing identifying anything. Only your Windows user name and the file name could potetially say something. I don't see any reason why this should be deleted. I will also restore your question from the Google Cache.
If you disagree, feel free to contact Mathworks support. They have full discretion to delete posts, or take steps to appropriately anonymize a post.
When you posted this code you agreed to the terms of use, which allows anyone to republish your post (with some limitations, and with attribution).
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?
Yes sir now this editing is fine for me. can u pls do the same for the provided answer?

Sign in to comment.

 Accepted Answer

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 Comments

How on earth can 3-letter abbreviations be confidential? Can you explain that? I genuinely don't understand.
sir that was a request from my side. pls consider it.
@Shrutidat: You are aware that the original versions are still stored in the caches of the internet search engines?
Sir thank u so much 😭😭 And I'm really sorry for all the trouble 🥺

Sign in to comment.

More Answers (0)

Products

Release

R2021a

Asked:

on 10 Apr 2022

Commented:

on 20 May 2022

Community Treasure Hunt

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

Start Hunting!