永发信息网

关于MATLAB问题

答案:1  悬赏:50  手机版
解决时间 2021-05-07 02:41

function [mag, angle] = polar_value(x,y)

% POLAR_VALUE Converts (x,y) to (r,theta)

% Function POLAR_VALUE converts an input (x,y)

% value into (r,theta), with theta in degxees.

% It illustrates the use of optional arguments.

% Define variables:

% angle -- Angle indegrees

% msg -- Error message

% mag -- Magnitude

% x -- Input x value

% Y -- Input y value (optional)

% Record of revisions:

% Date Programmer Description of change

% ==== ========== =====================

% 12/16/98 S. J. Chapman Original code

% Check for a legal number of input argnments.

msg = nargchk(1,2,nargin);

error (msg);

% If the y argument is missing, set it to 0.

if nargin < 2

y = 0;

end

% Check for (0,0) input arguments, and print out

% a warning message.

if x == 0 & y == 0

msg = 'Both x and y are zero: tingle is meaningless! ' ;

warning (msg);

end

% Now calculate the magnitude.

mag = sqrt(x.^2 + y.^2);

% If the second output argument is present, calculate

% angle in degrees.

if nargout == 2

angle = atan2 ( y , x ) * 180/pi;

end

把这个程序的默认输入值由y=0改成x=0

最佳答案
把这个

if nargin < 2


y = 0;


end


改为


if nargin < 2


x = 0;


end

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
请问疯前状态
粉底膏干了怎么办,make up forever眼线膏干掉
金鼎盛娱乐城在哪里啊,我有事要去这个地方
有多少年轻女孩在的呀?帮忙看看这样的情况怎
为什么我下载了QQ飞车新版本还贼王宝藏完不了
如何解决犯困?
地下城我27级了,让高手带哪个图经验最高!
难道爱一个人真的有错吗~
赣下面加个心念什么?
战魂怎么分解
水浒Q传SS套装
带梳子的诗句,关于梳子的句子
雅马哈天剑k多少钱?徐州价格。
丝路英雄怎么登起是这样的啊?????
有谁知道信基督的群的群号
推荐资讯
买卖的双方、谁先出价最据上峰?
博恒酒店用品地址有知道的么?有点事想过去
笔记本无线联网有几种方法?请详细点
更知乡怎么去啊,有知道地址的么
小米手机右上角时间的颜色怎么改
在郁南坐车到深训要多久?
方正书版如何排双色书
冒险岛刀飞从10级以前怎么加点,10级后怎么加
QQ音信图标,需要好友帮忙,可我的好友都没点
怎样去除脸上的豆豆?
qq游戏总动员答案 宝石总换什么时间更新
仙剑4神龙和玄霄还有玄女那个厉害
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?