필터 지우기
필터 지우기

syntax for plot functions

조회 수: 1 (최근 30일)
goran
goran 2014년 1월 5일
댓글: Image Analyst 2014년 1월 5일
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

답변 (2개)

Mischa Kim
Mischa Kim 2014년 1월 5일
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
Image Analyst
Image Analyst 2014년 1월 5일
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
goran 2014년 1월 5일
in second function
when i type f2=sinh(x+1)+tan(x.^2)/tan(x)+abs(1-sin(1/(x.^2+1))) i receive error Error using / Matrix dimensions must agree. error is showing because sin(1/(x.^2+1) why?
  댓글 수: 1
Mischa Kim
Mischa Kim 2014년 1월 5일
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.

댓글을 달려면 로그인하십시오.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by