How do I enter the equation and plot points?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!