Horzcat function joins 1 end of line to the other end.

1 view (last 30 days)
Hi there, if you can see from my data, there's a problem with the graph. the point on the Left joins with the point around zero on the X-axis. I know that this is because of horzcat but I need to use horzcat for a later point. Can anyone come up with a solution as I've triped swapping the range at the start and it says 'vectors must be the same length' This is my code:
[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 = E(1)/24 - cumsum(fliplr(diff(x1)));
y2 = y1(1:end-1);
x = horzcat(x2, x1);
y = horzcat(y2, y1);
plot(x, y)

Accepted Answer

Walter Roberson
Walter Roberson on 7 Nov 2015
x = horzcat(x2, nan, x1);
y = horzcat(y2, nan, y1);

More Answers (0)

Categories

Find more on Graphics Object Properties 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!