Hi there, I'm currently making my dissitation on free-stream velocity fluctuation in tides. Spring tides (highest velocity) occur twice in a lunar cycle and neap tides (lowest velocity) occur also twice in a lunar cycle. Lunar cycles occur every 29.53 approximately with Spring tides and neap tides a quarter of a cycle apart. I'm trying to simulate the the fluctuation, however I've come across a couple of problems. There is phase shift which I haven't included because shifting the initial graph would also mean changing the initial amplitude. I've tried doing It this way but I just get further problems later on. I've also chosen to further the range by adding an additional quarter forward of time and before x = 0 in case of phase shift. What I want to do is first of all eliminate the problem of the reflected wave before x=0 and the wave after x=0 not being joined together, secondly shift the wave by E(k)/24, and thirdly limit the x-axis between 0 and 29.53 so that the wave can only be seen between 0 and 29.53. I've attached the Excel file that's imported.
[data, titles, r]=xlsread('Tidal Sites.xlsx');A=data(:,4); %Amplitude
B=data(:,10); %Exponential decrease
C=data(:,11); %Frequency
E=data(:,6); %Number of hours difference spring tide is relative to dover
F=titles(:,2); %Site name
for k=1:length(E) if ~isnan(E(k)) x1=linspace(0, 7.3826475, 10000); y1=det(A(k))*((exp(1).^(det(-B(k)).*x1))).*cos((det(C(k)).*x1)); figure, plot(x1,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 = 0 - cumsum(fliplr(diff(x1))); y6 = y1(1:end-1); %an additional quarter of cycle to make up for phase difference BEHIND
x = horzcat(x1, x2, x3, x4, NaN, x5, NaN, x6); y = horzcat(y1, y2, y3, y4, NaN, y5, NaN, y6); plot(x, y), hold on title(F(k+1)) xlabel('Time (days)') ylabel('Free-stream velocity (m/s)')%Problem arises at x = 0 where the reflected curve lines don't join
endend
Best Answer