Please help to solve this in Matlab

3 Comments

This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
@Steven Lord I have posted my code here. I'm not sure where it went wrong as I always getting error code. Please help to check where should I make the correction.
height = 1800/1000;
radius = 1100/2000;
pi = 3.14;
disp(pi*radius*radius*height);
pi=3.14;
base_area = pi*radius_m*radius_m;
daily_chart = [1 1200 0.99;2 1200 0.50;3 1400 0.21;4 1600 0.91;5 1800 0.90;6 1200 0.71;7 1000 0.00;8 1500 0.00;9 1600 0.50;10 1700 0.39;11 1200 0.03;12 1300 0.72;13 700 0.76;14 400 0.08];
%%
height_m=height/1000;
radius_m=diameter/2000;
disp(base_area*height_m);
%%
daily_vol=zeros([14 1]);
daily_rain=zeros([14 1]);
v=zeros([14 1]);
h_avg=0;
max_day=1;
max_vol=daily_chart(1,3);
for i = 1:14
daily_rain(i)=daily_chart(i,3);
v(i)=daily_chart(i,2);
daily_vol(i,1)=(base_area*daily_chart(i,2)/1000) + daily_chart(i,3);
h_avg=h_avg+(daily_vol(i,1)/base_area);
if(max_vol<daily_chart(i,3))
max_vol=daily_chart(i,3);
max_day=i;
end
end
h_avg=h_avg/14;
disp("Average Liquid level in tank is "+h_avg);
disp("Most collectable rain is on Day "+max_day+" and the volume is "+max_vol);
%%
% Plotting graphs for part e:
f=figure;
nexttile
plot(daily_rain,'-o',Color='green');
title("Rainwater vs Day");
xlabel("Day");
ylabel("Rainwater Collected");
nexttile
plot(v,'-.',Color='black')
title("Liquid Volume vs Day");
xlabel("Day");
ylabel("Total Volume of Water");
%%
% Plotting graphs for part f:
f1=figure;
nexttile
plot(daily_vol);
title("Total Volume vs Day");
xlabel("Day");
ylabel("Total Volume");

Sign in to comment.

Answers (1)

height = 1800/1000;
radius = 1100/2000;
pi = 3.14;
disp(pi*radius*radius*height);
pi=3.14;
base_area = pi*radius_m*radius_m;
daily_chart = [1 1200 0.99;2 1200 0.50;3 1400 0.21;4 1600 0.91;5 1800 0.90;6 1200 0.71;7 1000 0.00;8 1500 0.00;9 1600 0.50;10 1700 0.39;11 1200 0.03;12 1300 0.72;13 700 0.76;14 400 0.08];
%%
height_m=height/1000;
radius_m=diameter/2000;
disp(base_area*height_m);
%%
daily_vol=zeros([14 1]);
daily_rain=zeros([14 1]);
v=zeros([14 1]);
h_avg=0;
max_day=1;
max_vol=daily_chart(1,3);
for i = 1:14
daily_rain(i)=daily_chart(i,3);
v(i)=daily_chart(i,2);
daily_vol(i,1)=(base_area*daily_chart(i,2)/1000) + daily_chart(i,3);
h_avg=h_avg+(daily_vol(i,1)/base_area);
if(max_vol<daily_chart(i,3))
max_vol=daily_chart(i,3);
max_day=i;
end
end
h_avg=h_avg/14;
disp("Average Liquid level in tank is "+h_avg);
disp("Most collectable rain is on Day "+max_day+" and the volume is "+max_vol);
%%
% Plotting graphs for part e:
f=figure;
nexttile
plot(daily_rain,'-o',Color='green');
title("Rainwater vs Day");
xlabel("Day");
ylabel("Rainwater Collected");
nexttile
plot(v,'-.',Color='black')
title("Liquid Volume vs Day");
xlabel("Day");
ylabel("Total Volume of Water");
%%
% Plotting graphs for part f:
f1=figure;
nexttile
plot(daily_vol);
title("Total Volume vs Day");
xlabel("Day");
ylabel("Total Volume");

Asked:

on 9 Nov 2022

Commented:

on 10 Nov 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!