How to make a piecewise function?
显示 更早的评论
I just want to plot the 3D function that makes a rollercoaster track. I have done it succesfully in 2D in desmos using arcs of circles through both implicit and parametric functions which I have attached.
I can not create a piecewise function that represents what I have in either desmos images.
What should I be putting into MATLAB to get the desmos equivalent? Is my piecewise failing because of the domain restrictions?
I have tried to make a piecewise function for only the x axis. The plan was to make 3 piecewise functions for x y and z, then to plot the 3 piecewise functions. Using the following command:
pwx = piecewise(0<=t<=pi/2,f1x,pi<=t<=3*pi/2,f2x,3*pi/2<=2*pi,f3x,0<=t<=pi,f4x,pi<=t<=3*pi/2,f5x)
where
f1x = @(t) 2*cos(t);
f2x = @(t) cos(t);
f3x = @(t) 2*cos(t)+3;
f4x = @(t) cos(t)+4;
f5x = @(t) 2*cos(t)+5;
and
t = linspace(0,3*pi/2)
I get the error message:
Undefined function 'piecewise' for input arguments of type 'function_handle'.
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
