Matlab 出现的子函数输出问题.源M文件如下:&&&&&&&&&&&&&&&function [taxb,taxa,diff]=homework1income=input('yourincome:','s');type=input('yourtaxtype:(1 is for single,2 is for company)','s');ty=(type-1)*2;tyy=ty+4;y=whichstep(income,ty);
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 03:04:24
Matlab 出现的子函数输出问题.源M文件如下:&&&&&&&&&&&&&&&function [taxb,taxa,diff]=homework1income=input('yourincome:','s');type=input('yourtaxtype:(1 is for single,2 is for company)','s');ty=(type-1)*2;tyy=ty+4;y=whichstep(income,ty);
Matlab 出现的子函数输出问题.
源M文件如下:
&&&&&&&&&&&&&&&
function [taxb,taxa,diff]=homework1
income=input('yourincome:','s');type=input('yourtaxtype:(1 is for single,2 is for company)','s');
ty=(type-1)*2;tyy=ty+4;
y=whichstep(income,ty);yy=whichstep(income,tyy);
taxa=coculate(y,ty,income);taxb=coculate(yy,tyy,income);
diff=taxb-taxa;
printf('diff is tax before cut after');
function y=whichstep(income,t)
[m,n]=which1(t);
rows=size(t);
for k=1:rows
x=m(k);
if income>x
y=x;
end
end
function a=coculate(y,t,income)
[m,n]=which1(t);
for k=1:y
if =y
a=a+(m(k+1)-m(k))*n(k)/100;
else a=a+(income-m(y))*n(y)/100;
end
end
function [m,n]=which1(t)
a=[0,500,2000,5000,20000,40000,60000,80000,100000];
b=[5,10,15,20,25,30,35,40,45];
c=[0,5000,10000,30000,50000];
d=[5,10,20,30,35];
e=[0,1500,4500,20000,40000,60000,80000];
f=[10,20,25,30,35,45];
g=[0,15000,30000,60000,100000];
h=[5,10,20,30,35];
if t==0
m=a ;n=b;
end
if t==2
m=c ;n=d;
end
if t==4
m=e; n=f;
end
if t==6
m=g; n=h;
end
&&&&&&&&&&&&&&&
Error in homework1>which1 (line 30)
a=[0,500,2000,5000,20000,40000,60000,80000,100000];
Output argument "m" (and maybe others) not assigned during call to "D:\homework1.m>which1".
Matlab 出现的子函数输出问题.源M文件如下:&&&&&&&&&&&&&&&function [taxb,taxa,diff]=homework1income=input('yourincome:','s');type=input('yourtaxtype:(1 is for single,2 is for company)','s');ty=(type-1)*2;tyy=ty+4;y=whichstep(income,ty);
% 也可以在 if...end 之外,m = 0; n = 0; 就可以了.