help to input sqrt function
1 次查看(过去 30 天)
显示 更早的评论
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 )
0 个评论
回答(2 个)
Walter Roberson
2020-6-10
编辑:Walter Roberson
2020-6-12
z = sqrt(sin(x.^2+y.^2)) ./ sqrt(x.^2+y.^2);
3 个评论
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
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
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!