필터 지우기
필터 지우기

plotting functions with range

조회 수: 1 (최근 30일)
goran
goran 2014년 1월 7일
답변: goran 2014년 1월 7일
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

답변 (3개)

Mischa Kim
Mischa Kim 2014년 1월 7일
편집: Mischa Kim 2014년 1월 7일
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 2014년 1월 7일
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 2014년 1월 7일
yes, range in x values. my task is to explain why i use certain range for specific function

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by