How to plot an equation qith specific data range?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello
I have a question about a code. I would like to plot an equation in a plot. But I would like to plot a specific data range of the equation.
E.g X values range from 0 to 100. But i would like to depict ONLY the values between 25-80for equation y.
clc
clear
x=0:5:100
y=3*x+10
y1=4*x+5
plot(x,y)
hold on
plot(x,y1)
could you please help me?
0 Kommentare
Antworten (1)
Joseph Cheng
am 3 Jun. 2021
For this you can use the function ylim()
clc
clear
x=0:5:100;
y=3*x+10;
y1=4*x+5;
plot(x,y)
hold on
plot(x,y1)
ylim([25 80])
2 Kommentare
Joseph Cheng
am 3 Jun. 2021
there are lots of ways but since you are not very clear...................
clc
clear
x=0:5:100;
y=3*x(x>=25&x<=85)+10;
y1=4*x+5;
subplot(211)
plot(x(x>=25&x<=85),y);
hold on
plot(x,y1);
subplot(212)
y=3*x+10;
[ax h1 h2]=plotyy(x,y,x,y1);
ylim(ax(1),[25 85])
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!