Trouble using ezplot and matlabFunction on a symbolic function defined using symengine "piecewise"

조회 수: 6 (최근 30일)
syms x t;
MP_syntax1 = 'piecewise([x <= 10, x/10], [10 < x <= 30, (30 - x)/20])';
MP_syntax2 = 'ilaplace(2/s^3,s,t)';
f(x) = evalin(symengine,MP_syntax1);
g(t) = evalin(symengine,MP_syntax2);
No trouble with g(t) or other MuPad functions:
ezplot(g(t), [-5,5]);
G = matlabFunction(g(t));
Trying the same to the piecewise, f(x) will not work however.
ezplot(f(x),[0,30]);
F = matlabFunction(f(x));
However, this works
xd = 0:0.1:30;
fd = double(f(xd));
plot(xd,fd);
What is wrong with the other calls using ezplot and matlabFunction for f(x) ?
  댓글 수: 4

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

채택된 답변

Sally Al Khamees
Sally Al Khamees 2016년 12월 23일
편집: Sally Al Khamees 2017년 2월 21일
If you have R2016b and the Symbolic Math Toolbox installed, you can just use the piecewise function:
For example:

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by