syntax for plot functions
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
i'm beginner in matlab. i try to type 3 functions and plot graphic for functions but i cannot do it. when i type
x=0.15; f1=1-x-x^2/(2+x)-x^3/(3+x)-x^4/(4+x)
i receive ok value. but when i type
x=-2:0.1:2; f1=1-x-x^2/(2+x)-x^3/(3+x)-x^4/(4+x)
i receive error
Error using ^
Inputs must be a scalar and a square
matrix.
To compute elementwise POWER, use POWER
(.^) instead.
when i change function on
f1=1-x-x.^2/(2+x)-x.^3/(3+x)-x.^4/(4+x)
i receive values but wrong values. when i try plot graph plot(x,f1) i receive straight line, but this function is hyperbole.same problem is with other functions. i attached those function in file
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154611/image.jpeg)
0 comentarios
Respuestas (2)
Mischa Kim
el 5 de En. de 2014
You need to use the dot notation all the way throughout the equation, e.g.,
f1 = 1 - x - x.^2./(2 + x) - x.^3./(3 + x) - x.^4./(4 + x)
1 comentario
Image Analyst
el 5 de En. de 2014
goran's own "Answer", which he also accepted for some reason, moved here so he can now accept Mischa's answer instead:
thank's. it's works. can you send link where i can find when i need to use the dot notation when not?
goran
el 5 de En. de 2014
1 comentario
Mischa Kim
el 5 de En. de 2014
Same thing as before, you need to use element-wise division:
f2 = sinh(x + 1) + tan(x.^2)./tan(x) + abs(1 - sin(1./(x.^2 + 1)))
By the way, you accepted the answer to the answer.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!