Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am using Octave but I think it applies to MatLab too, so I'm tagging this MatLab since there isnt a Octave tag

When I do

x=linspace(-5,5,25)
y=1/x

I get

error: operator /: nonconformant arguments (op1 is 1x1, op2 is 1x25)

Or

x=linspace(-5,5,25)
y=x^2

I get

error: for A^b, A must be square

How can I then plot the graphs of each?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Try:

x=linspace(-5,5,25)
y = 1./x
plot(x,y)

x=linspace(-5,5,25)
y=x.^2
figure
plot(x,y)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.