Please answer the following matlab question: example help: write code that track
ID: 3824687 • Letter: P
Question
Please answer the following matlab question:
example help:
Explanation / Answer
Solution:
function k=how_much_new_snow()
k= round(0 + (10).*rand(1,1));
end
function k1=odd(val)
if mod(val,2)==0
k1=0;
else
k1=1;
end
end
% Initial value
count=0;
snow=[0 10 4];
sz=length(snow)
budget=100;
for day=1:1:sz
budget=budget+10;
amt=how_much_new_snow()
for i=1:sz
snow(i)=snow(i)+amt;
end
if amt>0
total=0;
for n=1:sz
total=total+snow(n);
end
budget=budget+0.2*total;
if odd(day)==1
for m=1:3
if odd(m)==1
snow(m)=0;
end
end
else
for m=1:sz
if odd(m)==0
snow(m)=0;
end
end
end
else
for m=1:sz
if snow(m)>0
snow(m)=snow(m)-1;
if budget>0
budget=budget-1;
else
count=count+1;
end
end
end
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.