2013-08-04 91 views
0

我的M-文件:刪除ANS輸出

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.00

ANS =

4 

我想刪除 ANS = 4 .. 怎麼會我這樣做? 任何人都可以幫助我嗎?

回答

1

在端;將分號而主叫

>>salary; 
     ^^ semi-colon here 

當放置在命令結束時,分號告訴MATLAB不顯示從該命令任何輸出。