필터 지우기
필터 지우기

How to plot a curve when x(3,idx) is within a certain range

조회 수: 2 (최근 30일)
Atom
Atom 2023년 11월 30일
댓글: Atom 2023년 11월 30일
EDIT: modifies code to just load x, as otherwise there are a lot of warnings.
I want to plot a curve when x(3,idx) is whithin the range (6.077865,16.053016). How to do that? The code below makes the whole curve for (6.077865,20) red. I want to get a red curve for (6.077865,16.053016) and blue curve for (16.053016,20). Please help.
load('EP_EP(2).mat','x');
idx = x(3,:)>16.053016;
plot(x(3,idx),x(1,idx),'b', 'LineWidth',2)
hold on
idx = 6.077865<x(3,:)<16.053016;
plot(x(3,idx),x(1,idx),'r', 'LineWidth',2)
axis([0 20 0 .8]);

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 30일
편집: Dyuman Joshi 2023년 11월 30일
In MATLAB, when using multiple conditions to compare, the conditions need to be specified separately -
idx = 6.077865<x(3,:) & x(3,:)<16.053016;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by