piecewise function plot issue,

16 ビュー (過去 30 日間)
Batuhan Gülcan
Batuhan Gülcan 2018 年 1 月 12 日
回答済み: Aveek Podder 2018 年 1 月 29 日
hi im working on a very easy piece of code actually but i cannot seem to plot the proper graph.
syms x;
p1=piecewise(x<2, 7.5*x, x>=2&x<3, 5*x+5,x>=3&x<5,20)
p2=piecewise(x>=5&x<7, -20 ,0)
fplot(x, p2)
xlim([0 12])
ylim([-30 30])
p1 plots just fine. the expression p2 should actually be longer and embedded in p1 but I extracted the code from the point it was not working anymore.
the goal is to build the following graph.
would appreciate some help. thanks!!

回答 (1 件)

Aveek Podder
Aveek Podder 2018 年 1 月 29 日
By default, fplot has a xinterval of [-5,5]. Passing the desired xinterval as an argument should solve the issue.
fplot(p2,[0 12])
For more information on fplot please follow this Link.

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by