How to make a graph from each row of data?

2 views (last 30 days)
I need to make graphs for each row imported from an excel spread sheet. I have made a graph for the first row from my tables, using E(1) for example for the first set of data. I have attached the excel spreadsheet also for your reference.
[data, titles, r]=xlsread('Tidal Sites.xlsx');
A=data(:,9);
B=data(:,10);
C=data(:,11);
D=data(:,12);
E=data(:,6);
F=titles(:,2);
x1=linspace(E(1)/24., 7.3826475+(0.527331964/2)+(E(1)/24), 10000);
y1=det(A(1))*((exp(1).^(det(-B(1)).*x1))).*cos((det(C(1)).*x1)+det(D(1)));
figure, plot(x1,y1), hold on
x2 = x1(end) + cumsum(fliplr(diff(x1)));
y2 = fliplr(y1(1:end-1));
x3 = x2(end) + cumsum(fliplr(diff(x2)));
y3 = fliplr(y2(1:end-1));
x4 = x3(end) + cumsum(fliplr(diff(x3)));
y4 = fliplr(y3(1:end-1));
plot(x1, y1, x2, y2, x3, y3, x4, y4), hold on
title(F(1+1))
xlabel('Time (days)')
ylabel('Free-stream velocity (m/s)')

Accepted Answer

Geoff Hayes
Geoff Hayes on 25 Oct 2015
Ellis - if you wish to create a new figure for each new "graph" that you plot, then just iterate over each row of E (and subsequently, over each row of A, B C, D, and F). Try something like
for k=1:length(E)
if ~isnan(E(k))
x1=linspace(E(k)/24., 7.3826475+(0.527331964/2)+(E(k)/24), 10000);
y1=det(A(k))*((exp(1).^(det(-B(k)).*x1))).*cos((det(C(k)).*x1)+det(D(k)));
figure, plot(x1,y1), hold on
% etc.
title(F(k+1))
xlabel('Time (days)')
ylabel('Free-stream velocity (m/s)')
end
end
As some of your data within E is NaN, then we can exclude this data with the ~isnan(E(k)) check. Try the above and see what happens!

More Answers (0)

Categories

Find more on 2-D and 3-D Plots 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!