Piecewise Function (Toolbox Doesn't Work)
4 次查看(过去 30 天)
显示 更早的评论
Hi,
When I try to create a piecewise function with the Symbolic Math Toolbox, it says unrecognized. I cleared the toolbox path cache and reset paths to default. I checked "which ~all <piecewise>" but it's like it doesn't exist.
After creating a piecewise function, I need to plot it discretely. It should look like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1601991/image.png)
n2=-2:0.5:0;
f2 = @(n2) (0);
hold on
n=0:0.5:5;
f = @(n) (3*exp(-n).*sin(pi*n));
figure;
stem(n, f(n));
TIA
2 个评论
Dyuman Joshi
2024-1-28
Do you have the Symbolic Math Toolbox installed?
Type "ver" in the command window and check the output.
采纳的回答
Matt J
2024-1-28
编辑:Matt J
2024-1-28
Why bother with symbolic math? Why not just plot as below?
n=linspace(-2,5);
f = @(n) (3*exp(-n).*sin(pi*n)).*(n>=0);
plot(n,f(n),'b',n, 3*exp(-n),':r'); ylim([-3,3])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!