多做题,通过考试没问题!

MATLAB语言考试

睦霖题库>其他计算机考试>MATLAB语言考试

利用函数文件,实现直角坐标(x,y)与极坐标(ρ,θ)之间的转换。已知极坐标的矢径、极角分别为:

正确答案: 函数文件:
文件名:transform
程序:
function[r,theta]=transform(x,y)
r=sqrt(x*x+y*y);
theta=atan(y/x);
函数调用:
程序:
x=input(’Pleaseinputx=:’);
y=input(’Pleaseinputy=:’);
[r,theta]=transform(x,y);
disp([’矢径r为:’,num2str(r),’’,’极角theta为:’,num2str(theta)])
答案解析:
进入题库查看解析

微信扫一扫手机做题