How to draw the graph of a function that has different structure in its different domain
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
zahid
am 13 Dez. 2015
Beantwortet: Star Strider
am 13 Dez. 2015
Dear all suppose i want to find the graph of a function such that f(x)=4+x/(2+x^2) when x>0 and f(x)=4-x/(2-x^2) for x<=0 .How i can draw the two different forms of a function in different domain in a single graph with x-axis [-1,1].
0 Kommentare
Akzeptierte Antwort
Star Strider
am 13 Dez. 2015
Using logical indexing operations, this works:
f = @(x) (4+x./(2+x.^2)).*(x>0) + (4-x./(2-x.^2)).*(x<0); % Function
x = linspace(-1, 1, 250); % Define ‘x’
figure(1)
plot(x, f(x)) % Plot
grid
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Directed Graphs 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!