plotting functions with range
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
before i make a question about syntax typing functions but now how plotting these functions, which range that i use? these three functions are: f1=1-x-x.^2./(2+x)-x.^3./(3+x)-x.^4./(4+x) f2 = sinh(x + 1) + tan(x.^2)./tan(x) + abs(1 - sin(1./(x.^2 + 1))) f3=abs(1-x.^2)-exp(3+x.^2)+log10(x.^2)+cos(x/(1+x.^2))
For example for f2 function i used range x=-2:0.1:2 i receive graph
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154754/image.jpeg)
my function have brake. why? when i typed this function i receive graph
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154755/image.jpeg)
where is problem? which range that i use for functions f1, f2, f3. why i use those ranges? i would like that you send me explain? thanks
0 commentaires
Réponses (3)
Mischa Kim
le 7 Jan 2014
Modifié(e) : Mischa Kim
le 7 Jan 2014
For x = 0 MATLAB interprets the tan-term essentially as a 0 / 0 = NaN (not a number) and not tan(0) = 0 . This is because MATLAB computes the term numerically (as opposed to algebraically).
x = 0;
f2 = sinh(x + 1) + tan(x.^2)./tan(x) + abs(1 - sin(1./(x.^2 + 1)))
f2 =
NaN
As sort of a workaround, you can reduce the step size for x (e.g. x = -2:0.01:2; ) to make the gap between the two data points x = -0.01 and x = +0.01 smaller.
I am not sure I understand your question about range. Are you referring to the range in x values? Could you elaborate?
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!