How to plot section of a vector with a condition

조회 수: 2 (최근 30일)
Amit Pandey
Amit Pandey 2016년 3월 2일
댓글: Amit Pandey 2016년 3월 3일
Hello,
i am struggling with something. let me explain what exactly i need to plot. Suppose i have 4 vectors i.e Time, speed, torque, and power. say length of each vector is 15000x1. i want to plot time(x) vs speed(y),time(x) vs torque(y),time(x) vs Power(y). In all the three plots i don't want to shows points where power is less than a certain value. say power varies from 0 to 300. then in all the plots i don't want to show sections of plot whenever power is less than 225.
Thank you. -Amit

채택된 답변

Mike Garrity
Mike Garrity 2016년 3월 2일
I'm not clear on whether you want to connect across the skipped points, or leave them out. Here's an example that illustrates both:
npts=1000;
x=linspace(0,4*pi,npts);
y1=cos(x);
y2=sin(x);
mask=y1>.5;
figure
subplot(2,1,1)
plot(x(mask),y1(mask))
subplot(2,1,2)
plot(x(mask),y2(mask))
figure
subplot(2,1,1)
ytmp=y1;
ytmp(~mask)=nan;
plot(x,ytmp);
subplot(2,1,2)
ytmp=y2;
ytmp(~mask)=nan;
plot(x,ytmp);
  댓글 수: 3
Amit Pandey
Amit Pandey 2016년 3월 3일
hello ! the above command did not work. as i wanted the power points less than 225 were not "masked" in the speed and torque plots. is there any other way?
thanks -Amit
Amit Pandey
Amit Pandey 2016년 3월 3일
Got it corrected. works great now.

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

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by