Help Plotting Piecewise functions

조회 수: 3 (최근 30일)
Brianna Selles
Brianna Selles 2019년 9월 1일
댓글: madhan ravi 2019년 9월 1일
I need help plotting the following piecewise function. I attatched the question.
This is what I have so far:
syms x
y = piecewise(0<=x<=3, 4*x^1/3, 3<x<=6, pi^x+e) % this is the line that is saying there is an error.
fplot(y)

답변 (2개)

Walter Roberson
Walter Roberson 2019년 9월 1일
Chaining equalities like that is only supported in very recent MATLAB. Also you are using the wrong exponent:
y = piecewise(0<=x & x<=3, 4*x^1/3, 3<x & x<=6, pi^(x+e))
If e is intended to be the base of the natural logs then chances are you are going to need to define e as e is not built-in constant in MATLAB. e = exp(1);
  댓글 수: 9
Walter Roberson
Walter Roberson 2019년 9월 1일
syms x
e = exp(1)
y = piecewise(0<=x & x<=3, 4*x^1/3, 3<x & x<=6, pi^(x+e))
fplot(y,'c')

댓글을 달려면 로그인하십시오.


madhan ravi
madhan ravi 2019년 9월 1일
편집: madhan ravi 2019년 9월 1일
You are almost there , change e to exp()
syms x
y = piecewise(0<=x<=3, 4*x^1/3, 3<x<=6, pi^(x+e)) % Note the parentheses around pi
fplot(y,'c') % change this line
doc fplot % to see more examples

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by