MATLAB Answers

Silpa K
0

marking some points.

Asked by Silpa K
on 20 Sep 2019 at 14:37
Latest activity Commented on by Silpa K
on 20 Sep 2019 at 15:58
A=[0.8570, 1.0447 , 1.2136 , 1.3637 , 1.4670 , 1.4576 , 1.3731 , 0.9696 , 0.6505 , 0.2845]
B=[1.2136,.2845]
plot(A)
I need to mark the B points in the plot(A).Please help me.

  0 Comments

Sign in to comment.

Tags

1 Answer

Geoff Hayes
Answer by Geoff Hayes
on 20 Sep 2019 at 14:59
 Accepted Answer

Silpa - you could try something like
A=[0.8570, 1.0447 , 1.2136 , 1.3637 , 1.4670 , 1.4576 , 1.3731 , 0.9696 , 0.6505 , 0.2845]
B=[1.2136,.2845];
plot(A);
hold on;
plot(cell2mat(arrayfun(@(x)find(abs(A-x)<eps),B, 'UniformOutput',false)), B,'*');
where we use arrayfun to get the indices of the element of B in A (so that they are drawn at the correct coordinates).
Note that the above doesn't handle the case where the elements of B are NOT in A, so you would need to add code to guard against this.

  1 Comment

Silpa K
on 20 Sep 2019 at 15:58
Thank you sir for your help.

Sign in to comment.