0

alright well I have the follow function

y=sin(x)^2 + [(10+2x+x^2) / (5+2x^2)]

i need to plot it on the interval y = -2 to y = 2 so how would I set that up?

I did this in matlab

   >>  y = sin(x).^2 + (10 + 2*x + x.^2)/(5+2*x.^2)
   >>  x = -2:0.01:2;

is that a correct setup? Or have I done something wrong

4

2 回答 2

7

You need to declare a variable before you use it. In this case, x doesn't depend on y, so declare it first. In addition, there is a ./ operator missing.

x = -2:0.01:2;
y=sin(x).^2 + (10+2*x+x.^2) ./ (5+2*x.^2);
plot(x,y)
于 2012-11-20T22:56:16.560 回答
0
f = @(x) sin(x)^2 + [(10+2*x+x^2) / (5+2*x^2)];
ezplot(f)
于 2020-04-13T02:49:18.060 回答