MATLAB Answers

Can anyone give me the exact statement I must use to prevent this additional line from coming between the plot extremities?

1 view (last 30 days)
utsav kakkad
utsav kakkad on 8 Jan 2019
Edited: utsav kakkad on 1 Feb 2019
Can anyone give me the exact statement I must use to prevent this additional line from coming between the plot extremities? Can anyone give me the exact statement I must use to prevent this additional line from coming between the plot extremities?
I am using this statement:
plot([r r+1],[STATISTICS(r).AVG STATISTICS(r+1).AVG],'green');
kindly do let me know if the code is needed I shall put it up

  0 Comments

Sign in to comment.

Accepted Answer

OCDER
OCDER on 8 Jan 2019
Seems like your X values are not sorted, causing the lines to loop around. To fix, sort your X and Y values. See example below:
X = [1:10 1]; % X goes back to 1
Y = sin(X);
plot(X, Y); %Similar to your situation
%To fix, sort your X and Y
[X, SortIdx] = sort(X);
Y = Y(SortIdx);
plot(X, Y); %Fixed

More Answers (0)

Products


Release

R2018a