marking some points.

조회 수: 2 (최근 30일)
Silpa K
Silpa K 2019년 9월 20일
댓글: Silpa K 2019년 9월 20일
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.

채택된 답변

Geoff Hayes
Geoff Hayes 2019년 9월 20일
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
Silpa K
Silpa K 2019년 9월 20일
Thank you sir for your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by