1
votes

My question is - How do I visualize these two functions enter image description here ; enter image description here.

For the first one, I've tried -

x=-2:0.1:2;
f=@(x)1/1+x.^2
plot(x,f(x))

And MATLAB doesnt allow me to place

1+x.^2

in parentheses. MATLAB tells me - 'Inner matrix dimensions must agree.'. Same issue with second function.

1
You don't need "element- wise-power" (the operator .^). Try just to use ^ like 1+x^2 - marcoresk
@marcoresk Incorrect. The element-wise operator is required or else for vectors and matrices, ^ would be interpreted as matrix exponentiation. - rayryeng

1 Answers

4
votes

Division needs to be pointwise, too. So you should do

x=-2:0.1:2;
f=@(x)1./(1+x.^2)
plot(x,f(x))