String 删除输出中的ans
我的m文件:String 删除输出中的ans,string,matlab,String,Matlab,我的m文件: function pay = salary h = input('Please enter the number of hours worked : '); w = input ('Please enter the hourly wage : $ '); pay = h*w; %this will add 50%of the hourly wage if it exceeds 40 hours if h>40 pay = pay+((h-40)*0.5*w);
function pay = salary
h = input('Please enter the number of hours worked : ');
w = input ('Please enter the hourly wage : $ ');
pay = h*w;
%this will add 50%of the hourly wage if it exceeds 40 hours
if h>40
pay = pay+((h-40)*0.5*w);
end
fprintf('The worker''s pay is $ %5.2f ', pay)
输出:
function pay = salary
h = input('Please enter the number of hours worked : ');
w = input ('Please enter the hourly wage : $ ');
pay = h*w;
%this will add 50%of the hourly wage if it exceeds 40 hours
if h>40
pay = pay+((h-40)*0.5*w);
end
fprintf('The worker''s pay is $ %5.2f ', pay)
薪水
请输入工作小时数:2
请输入小时工资:$2
工人的工资是4美元
ans=
4
我想把它移走
ans=4。。
我该怎么做?
有人能帮我吗?在末尾加个分号
代码>呼叫时
>>salary;
^^ semi-colon here
当放在命令末尾时,分号告诉MATLAB不要显示该命令的任何输出