This is a similar graph to what i have.
keeping in mind the values of Y-axis always changes differently when i run the script on different data
What code do i need to add to find the exact begining point of the Y-axis when increasing at (-1) at point of X-axis
and find the exact point of it Y-axis when it reach (1) in x axis.
Is it possible to give out the subtraction point of X(2)-X(1) and presented in [legend]
unfortunatly i dont want to use any of the figure functions

 Réponse acceptée

Try something like this —
x1 = -2:2;
y1 = [0 0 1 0 0];
x2 = linspace(-2, 2);
y2 = interp1(x1, y1, x2);
[maxy2,idx2] = max(y2);
XP(1) = find(diff(y2(1:idx2))>0, 1, 'first')+1;
XP(2) = find(diff(y2(idx2+1:end))==0, 1, 'first')+idx2;
figure
plot(x1,y1,'-b')
hold on
plot(x2, y2, '--g', x2(XP), zeros(size(XP)),'+r')
hold off
text(x2(XP),[0 0], compose('\\leftarrow %.1f',x2(XP)), 'Horiz','left', 'Vert','middle', 'Rotation',90)
Since I have no idea how continuous the actual data are, I interpolated them here to find the points-of-interest with higher resolution.
.

Plus de réponses (1)

KSSV
KSSV le 21 Oct 2021
Let y be your array.
idx = find(y==1) ;
iwant = idx(1)-1

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Produits

Version

R2020a

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by