## Trending News

Promoted

# Matlab問題

fill in the blank in the following progra so that it multiplies all the negative integers between a and b

(include the endpoint, a and b, in your inteval)

(the variable my_total will contain this desired product, or it should equal 1 if there are no negative integers in the given interval)

clear;

a=80;

b=-3;

my_total=________

if______

left_num=_______

right_num=_______

else

left_num=_______

right_num=_______

end

for index=_________

if________

my_total=__________;

end

end

total

我是一個初學者

但是老師卻出這種問題= =" 讓我很無奈

拜託各位大大幫幫我想想怎樣寫這題

感謝您~

### 1 Answer

Rating

- ChaosLv 71 decade agoFavorite Answer
以下應該正確吧

clear;

a=80;

b=-3;

my_total=1

if a<0

left_num=b

right_num=a

else

left_num=b

right_num=0

end

for index=left_num:right_num

if index<0

my_total=my_total*index;

end

end

my_total

Source(s): 教學經驗

Still have questions? Get your answers by asking now.