필터 지우기
필터 지우기

How to set limit on 2 lines when data is from matrix

조회 수: 4 (최근 30일)
Austin Hernandez
Austin Hernandez 2020년 4월 27일
댓글: Austin Hernandez 2020년 4월 30일
Hello, I have this graph:
I am trying to limit the green line to ranges of X = A to B (A being the teal vertical line and and B is the maroon vertical line) and limit the purple line from B to 16.
The lines are plotted from a matrix with size of (1, 1601), and its calculated from a function where X goes from 0-16 . How can I keep the lines within the area I mentioned?

채택된 답변

Samatha Aleti
Samatha Aleti 2020년 4월 30일
편집: Samatha Aleti 2020년 4월 30일
Hi,
You may change the data points to “NaN” if you don’t want to plot those data points. Here is a sample code:
x = [1:15; 2:2:30]
one = x(1,:); % First line
two = x(2,:); % Second line
pH = 2:16; % Let
plot(pH, one); hold on; plot(pH, two);legend('one','two') % Actual plot
% Limit the range
one(pH > 10) = NaN;
two(pH < 10) = NaN;
figure
plot(pH, one); hold on; plot(pH, two);legend('one','two')
  댓글 수: 1
Austin Hernandez
Austin Hernandez 2020년 4월 30일
Thank you, although I figured it, it looks like this method will work as well, and may even be less work than my solution.
Basically, I used logical idexing to specify the indices where pH>10 and pH<13 and then used that to plot.
Thanks anyways!

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

추가 답변 (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