Reflect about y-axis after certain point in x.
9 views (last 30 days)
Show older comments
I'm trying to simulative tidal wave and reflect the wave about the x-axis after 1 quarter of a lunar cycle.
What I want is to mirror about the x-axis what i currently have after x = 7.3826475.
This is my coding for the first quarter and what it looks importing data from an excel spreadsheet to give a damped sinusoidal shape.
data=xlsread('Tidal Sites.xlsx');
A=data(:,9);
B=data(:,10);
C=data(:,11);
D=data(:,12);
x1=linspace(0., 7.3826475, 10000);
y1=det(A(1))*((exp(1).^(det(-B(1)).*x1))).*sin((det(C(1)).*x1)+det(D(1)));
figure, plot(x1,y1), hold on
0 Comments
Accepted Answer
Walter Roberson
on 18 Oct 2015
y2 = fliplr(y1);
x2 = x(end) + cumsum(mean(diff(x1)) * (1:length(x1)));
Note: the use of linspace for x does not actually give us enough information to construct as many more x values as already exist, only one fewer than that. linspace() is not equal interval, due to round-off considerations. The information that we can justify from the input values as a true reflection is
x2 = x(end) + cumsum(fliplr(diff(x)));
which will be one item shorter. The corresponding y is
y2 = fliplr(y1(1:end-1));
It depends on whether you want the last y to be duplicated or not. If the mirror is "at" the last value then the last should not be duplicated.
0 Comments
More Answers (0)
See Also
Categories
Find more on Line 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!