Plotting two linear equations
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sam Oznc
am 16 Mär. 2018
Kommentiert: Star Strider
am 17 Mär. 2018
Hi. How can i plot this equation between (-5,2) values
f(x) =
- -1 ----> x<-1
- x^2+x ------> -1 <= x < 2
0 Kommentare
Akzeptierte Antwort
Star Strider
am 16 Mär. 2018
Use ‘logical indexing’:
x = linspace(-5,2);
f = @(x) (-1).*(x < -1) + (x.^2 + x).*((x >= -1) & (x < 2));
figure(1)
plot(x, f(x))
grid
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calculus 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!