0
clear

for I = 1:1:41
    Result(I) = sqrt((I-1)*5+20)
end
plot(result)


The above is an example from my lab book. I want to do the same kind of thing except plotting the graph 4x^2-3x+2 where x is from 0 to 10 in steps of 0.5.
it doesn't seem to work when i substitute x for I though?
could someone help me out?

2
  • Seems like a homework, please add the homework tag if it is. Commented Jul 24, 2011 at 6:41
  • 1
    @Luke Gilling, take a look at the example in the provided answer. The key takehome is the way in which you generate the array that you desire. Be careful with mathematical operations on the elements. Note in the answer that .^ is used instead of ^. There are similar operators for multiplication and divide, all of which operate on the arrays / matrices point-wise--which is what you need. Commented Jul 24, 2011 at 12:42

1 Answer 1

1
x=0:0.5:10;
plot(x, 4*x.^2-3*x+2);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.