Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can I get explanation for each line? Do not included the Ends. function k=how_mu

ID: 3832573 • Letter: C

Question

Can I get explanation for each line? Do not included the Ends.

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

Explanation / Answer

%here is 3 matlab file in which 2 are function and 1 script

%explanation is given in percent with code

how_much_new_snow.m

function k=how_much_new_snow() %k is output and how_much_new_snow is function name
k= round(0 + (10).*rand(1,1)); %rand return 1 by 1 matrix of random value and round, rounds the elements of bracket to the nearest integers.
end

odd.m

function k1=odd(val) %k1 is output and odd is function name and val is input argument to function
if mod(val,2)==0 %if condition check if val is even or odd and mod gives Modulus after division.
k1=0;
else
k1=1;
end
end

main.m

% Initial value
clc%Clear command window.
clear%Clear variables and functions from memory.
count=0;
snow=[0 10 4]; %vector snow is made.
sz=length(snow) %Length of vector.
budget=100;
for day=1:1:sz %for loop from 1 to sz with increment size 1.
budget=budget+10;
amt=how_much_new_snow() %function called.
for i=1:sz %for loop from 1 to 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 %odd function is called
for m=1:3
if odd(m)==1 %odd function is called
snow(m)=0;
end
end
else
for m=1:sz
if odd(m)==0 %odd function is called
snow(m)=0;
end
end
end
else
for m=1:sz
if snow(m)>0
snow(m)=snow(m)-1; %decrease snow vector by 1
if budget>0
budget=budget-1; %increment budget by 1
else
count=count+1; %increment count by 1
end
end
end
end
end

Output :-


sz =

3


amt =

3


amt =

5


amt =

10

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote