simple functions in MATLAB

时间:2016-12-09 12:58:55

标签: matlab

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 个答案:

答案 0 :(得分:4)

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))
相关问题