Plotting a function with three regions
显示 更早的评论
Hi,I have been plotting various functions on matlab but I can’t wrap my head around this one, how can I write or plot this function when it has three values in three regions?

1 个评论
Use "piecewise" or define
g = @(n) -3*(n>=-4 & n <=2) + 2*(n>=3 & n<=5)
回答(1 个)
Walter Roberson
2023-5-1
0 个投票
See https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html for information on how to use Logical Indexing
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!