How do I enter the equation and plot points?
显示 更早的评论
Hello, I'm new to MATLAB and I'm with problems. I need to create a program that scan an equation like y=x+1 and plot 1000 points in the same graphic. I tried creating matrix, usin loops for and while but they didn't work. I create this program that work almost well.
xmin=input('Enter the lowest value of x: ');
xmax=input('Enter the largest value of x: ');
for i=1:1000
X(i)=xmin+(xmax-xmin)*rand(1)
end
[Y]=input('Enter the equation using "X" as the variable: y=');
plot(X,Y)
It works when I enter using some equation like X+1, but when I try another like sin(X) or X.^2 it didn't work like I want. Sorry for my English. Thanks Vinícius
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 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!
