필터 지우기
필터 지우기

help to input sqrt function

조회 수: 3 (최근 30일)
marwan alamah
marwan alamah 2020년 6월 10일
댓글: Walter Roberson 2020년 6월 12일
z=sqrt(sin(x.^2+y.^2))\sqrt(x.^2+y.^2)
is this code input correct for this function
z=(sin√(x^2+y^2 ))/√(x^2+y^2 )

답변 (2개)

Walter Roberson
Walter Roberson 2020년 6월 10일
편집: Walter Roberson 2020년 6월 12일
z = sqrt(sin(x.^2+y.^2)) ./ sqrt(x.^2+y.^2);
  댓글 수: 3
marwan alamah
marwan alamah 2020년 6월 10일
it did not work
tell me it is undefined function or variable x
what should i do
Walter Roberson
Walter Roberson 2020년 6월 12일
It is not clear why you would want to compute z=sqrt(sin(x.^2+y.^2))\sqrt(x.^2+y.^2) if x and y are not defined?
Perhaps you are wanting to create a function. If so then Rohith Nomula's "myfun" would work.

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


Rohith Nomula
Rohith Nomula 2020년 6월 10일
For this
z=(sin√(x^2+y^2 ))/√(x^2+y^2 )
For x and y as single elements
z=sin(sqrt(1^2+2^2))
z=z/(sqrt(1^2+2^2))
For a function
function z = myfuc(x,y)
z= sin(sqrt(x^2+y^2))/sqrt(x^2+y^2);
end
Try declaring it this way
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 6월 12일
The code to be implemented involves the dot versions of the operators, so the function should as well:
function z = myfuc(x,y)
z= sin(sqrt(x.^2+y.^2)) ./ sqrt(x.^2+y.^2);
end

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

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by