Superposition of all graphs
7 views (last 30 days)
Show older comments
I'm trying to find the overall effect of power production across each graph. Basically the graphs produced from the following code need to be added together, but as you can see there is phase shift, so as you see the graphs when running the code, that's exactly how they need adding. You will notice there is phase shift and this needs to remain where it is. I want to add all of the y-values together essentially and put them onto one graph, taking into perspective that there is phase shift in the sites. The X-range needs to remain at [0 29.53]. I've attached the Excel file that's imported. Thanks for looking into this :)
[data, titles, r]=xlsread('Tidal Sites.xlsx');
A=data(:,7);
B=data(:,10);
C=data(:,11);
D=data(:,12);
E=data(:,6);
F=titles(:,2);
G=data(:,14);
for k=1:length(E)
if ~isnan(E(k))
x1=linspace(0, 7.3826475, 10000);
y1=(abs(det(A(k))*((exp(1).^(det(-B(k)).*x1))).*cos((det(C(k)).*x1))));
figure, plot(x1 + E(k)/24 ,y1), hold on
x2 = x1(end) + cumsum(fliplr(diff(x1)));
y2 = fliplr(y1(1:end-1)); %Reflection after the first quarter of lunar cycle
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)); %2 more reflections to give lunar cycle
x5 = x4(end) + cumsum(fliplr(diff(x4)));
y5 = fliplr(y4(1:end-1)); % an additional quarter of cycle to make up for phase difference FORWARD
x6 = -cumsum(fliplr(diff(x1)));
y6 = y1(1:end-1); %an additional quarter of cycle to make up for phase difference BEHIND
x = horzcat(flip(x6), x1, x2, x3, x4, NaN, x5, NaN);
y = horzcat(flip(y6), y1, y2, y3, y4, NaN, y5, NaN);
plot(x + (E(k)/24), y), hold on
title(F(k+1))
xlabel('Time (days)')
ylabel('Power (GW)')
xlim([0 29.53]);
end
end
0 Comments
Accepted Answer
Image Analyst
on 21 Nov 2015
I didn't dig into this uncommented alphabet soup of a program, but you can align waveforms if you use normalized cross correlation, or normxcorr2() in the Image Processing Toolbox.
More Answers (0)
See Also
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!