How to plot a function that has a parameter in the interval?

Hello, I am new to MATLAB. I have a piecewise function as follows.
How do I plot the graph of such a function? Any help would be appreciated, thank you!

 採用された回答

Matt J
Matt J 2023 年 2 月 16 日
編集済み: Matt J 2023 年 2 月 16 日

0 投票

Using the Symbolic Math Toolbox (if you have it):
syms t
a=1;
f=piecewise(0<t & t<a, exp(t), t>=a, 2*exp(t));
fplot(f,[0,2*a])

2 件のコメント

Hanif
Hanif 2023 年 2 月 16 日
Thank you, Matt! This is a great answer, it helps me a lot.
Matt J
Matt J 2023 年 2 月 16 日
You are quite welcome, but please Accept-click the answer to indicate that it works for you.

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2023 年 2 月 16 日
編集済み: Matt J 2023 年 2 月 16 日

0 投票

One possibility:
a=1;
f=@(t) exp(t).*(0<t & t<a) + 2*exp(t).*(a<=t);
fplot(f,[0,2*a])

カテゴリ

製品

リリース

R2022b

質問済み:

2023 年 2 月 16 日

コメント済み:

2023 年 2 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by