Plotting multiple graphs from multiple ranges in excel
16 views (last 30 days)
Show older comments
I'm very very new to matlab and I need to produce a graph for each range of data for 49 specific timestamps
range = "C2:D41"; %increments by 40 each time ie next range is C42:D81 ect for 49 times
time = "H2"; %also increments by 40 each for each timestamp ie next timestamp text is at H42
%below needs to be in a loop that produces a new figure for each time if that's possible
[~,txtData] = xlsread("AllDataCollated.xlsx","Sheet2",time);
figure1 = xlsread("AllDataCollated.xlsx","Sheet2",range);
x = figure1(:,1);
y = figure1(:,2);
plot(x,y,'.')
title([txtData,"(HHMMSS)"])
xlabel("Xpixels")
ylabel("Ypixels")
grid
This creates the figure below, of which I need 48 more for the other times
any help would be greatly appreciated!
0 Comments
Answers (1)
Chad Greene
on 30 Apr 2021
The easiest way is probably to read the full range of data all at once, then loop through the different ranges you want to plot. So after reading the excel data,
x = figure1(:,1);
y = figure1(:,2);
hold on
for k=0:48
ind = (k*40+1):40*(k+1); % indices of data to plot. When k=0 ind equals 1 to 40. When k=1 ind equals 41 to 80
plot(x(ind),y(ind),'.')
end
2 Comments
Chad Greene
on 30 Apr 2021
If you want 49 subplots on the same figure, you could do it like this:
figure
for k = 0:48
subplot(7,7,k+1)
plot(rand(10,1),rand(10,1),'o')
axis tight
box off
title(['number ',num2str(k+1)])
end
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!