Borrar filtros
Borrar filtros

plotting functions with range

1 visualización (últimos 30 días)
goran
goran el 7 de En. de 2014
Respondida: goran el 7 de En. de 2014
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
my function have brake. why? when i typed this function i receive graph
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

Respuestas (3)

Mischa Kim
Mischa Kim el 7 de En. de 2014
Editada: Mischa Kim el 7 de En. de 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?

goran
goran el 7 de En. de 2014
for first function i used range x=-1.6:0.1:1.6 >> f1=1-x-x.^2./(2+x)-x.^3./(3+x)-x.^4./(4+x); >> plot(x,f1) i receive picture
maybe there is better range? which range you suggest and why? for second function i used x=-1.5:0.1:1.5; >> f3=abs(1-x.^2)-exp(3+x.^2)+log10(x.^2)+cos(x/(1+x.^2)); >> plot(x,f3) i received function
when i type function in wolframalpha i receive
which range you suggest and why?

goran
goran el 7 de En. de 2014
yes, range in x values. my task is to explain why i use certain range for specific function

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by