How to set limit on 2 lines when data is from matrix
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Austin Hernandez
am 27 Apr. 2020
Kommentiert: Austin Hernandez
am 30 Apr. 2020
Hello, I have this graph:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/288121/image.jpeg)
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?
0 Kommentare
Akzeptierte Antwort
Samatha Aleti
am 30 Apr. 2020
Bearbeitet: Samatha Aleti
am 30 Apr. 2020
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')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!