matlab中有无return,如何在matlab中控制返回变量(how to control return variable in matlab)

i want to clarify how to control returning of variables from function in matlab,for exmaple let us consider this code

function [x y z]=percentage(a)

n=length(a);

maximum=0;

minimum=0;

subst=0;

minus=0;

plus=0;

minus_perc=0;

plus_perc=0;

for i=1:1:n

if a(i)>0

plus=plus+1;

else

minus=minus+1;

end

end

minuc_perc=minus/n;

plus_perc=plus/n;

maximum=max(minus_perc,plus_perc);

minimum=min(minus_perc,plus_perc);

subst=maximum-minimum;

x=plus_perc;

y=minus_perc;

z=subst*100;

if plus_perc>minus_perc

disp('among the successful people,relevant propession was choosen by');

disp(z)

disp('% people');

else

disp('among the successful people,irrelevant propession was choosen by');

disp(z);

disp('% people');

end

end

what i want to return is plus_proc,min_proc and subst,but when i run following command,get result like this

[c d e]=percentage(a)

among the successful people,relevant propession was choosen by

58.3333

% people

c =

0.5833

d =

0

e =

58.3333

so i think something is wrong,array is like this

a =

1 -1 1 1 -1 1 -1 -1 1 1 1 -1

so ones again,i want to return plus_proc,minus_proc,and subst

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值