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일
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

Thank you, Matt! This is a great answer, it helps me a lot.
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일
One possibility:
a=1;
f=@(t) exp(t).*(0<t & t<a) + 2*exp(t).*(a<=t);
fplot(f,[0,2*a])

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

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