plotting a function with evenly spaced x values
6 次查看(过去 30 天)
显示 更早的评论
%i want to plot the function y=@(x) ((x.^2).*cos(pi.*x))/(((x.^3)+1).*(x+2)); where x increases from 0 to 1 in steps of 0.1
0 个评论
采纳的回答
Peng Li
2020-3-25
If you define x first, I believe it's easy to write down the y?
x = 0:0.1:1;
y = (x.^2).*cos(pi.*x)) ./ (((x.^3) + 1).*(x + 2);
plot(x, y);
Note: I believe that you should use ./ instead of / directly as it doesn't meet the requirement for matrix/vector division.
3 个评论
Peng Li
2020-3-25
using x = 0:0.1:1, you get 11 values between 0 and 1, with step 0.1. If you want 100 such values, you can use x = linspace(0, 1, 100);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!