creating plane piecewise in one plot

I am trying to plane something a piecewise function;
0<x<1 y=3x
1<x<2 y=2x+1
2<x<3 y=6x+1
ı have to plot that one graph, one function.

回答 (1 件)

Star Strider
Star Strider 2020 年 3 月 30 日

0 投票

Try this:
f = @(x) (3*x).*((0<x) & (x<=1)) + (2*x+1).*((1<x) & (x<=2)) + (6*x+1).*((2<x) & (x<=3));
x = linspace(0, 3);
plot(x, f(x))
grid

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

質問済み:

2020 年 3 月 30 日

回答済み:

2020 年 3 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by