plotting in for loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I tried to plot a linear continious graph but my graph shows only specific dots. I tried to turn my output data of for loop but an error comes up. Can anyone help me to plot a decent graph?
length_1 = 20; % house length parameters
length_2 = 10;
length_3 = 4;
beta = 40; % roof angle
N_win = 4; % number of windows
N_wall = 1; % number of walls "all in one'
areaWin = 1; % area of windows
areaWall = 236; % area off walls
thermWall = 136.8; % wall thermal coeffient
thermWin = 2808; % window thermal coeffient
thickWin = 0.07; % thickness of wind
thickWall = 0.2; % thickness of walls
airDen = 1.225; % air density
ca = 1.01; % thermal capasity of air
COP = 2; % coeffiecient of performance
P = 3; % power 3KW
Volume = (length_1*length_2*length_3) + (tand(beta)*length_1*length_2); %house volume
mass = Volume*airDen;
R_win = (1/N_win) * (thickWin/(thermWin*areaWin)); %resistance of windows
R_wall = (1/N_wall) * (thickWall/(thermWall*areaWall)); %resistance of walls
Rh = 1/(1/R_wall + 1/R_win); %paralel circuit
fprintf("Volume = %f\n",Volume)
fprintf("Mass = %f\n",mass)
fprintf("Walls' R = %f\n",R_wall)
fprintf("Windows' R = %f\n",R_win)
fprintf("Rh = %f\n\n",Rh)
deltaT = 0.1; %6 minutes period of an hour = 6/60
Tini = 19; %initial temp starts with fav temp of household's owner
Ptotal = 0; %total power consumption counter
for t = 12:0.1:16 %Time between 12-16 o'clock
Tout=0;
fprintf("Time = %.2f\n",t);
fprintf("Tin,h = %.2f\n\n",Tini);
plot(t,Tini,"r-o")
grid on
hold off
if (t>12) && (t<14.1)
Tout = 30; %12am-14am outside temperature
elseif (t>14) && (t<15.1)
Tout = 31; %14am-15am outside temperature
elseif (t>15) && (t<16.1)
Tout = 30; %15am-16am outside temperature
end
if Tini<21
U = 0; %HVAC is OFF
else
U = 1; %HVAC is ON
end
hold on
Tini=((1-(deltaT/(1000*mass*Rh)))*Tini+(deltaT/(1000*mass*Rh))*Tout-U*((COP*P*deltaT)/(0.000277*mass*ca)));
Ptotal = Ptotal + P*U; %total power
end
fprintf("Total Power Consumption = %.d KW\n",Ptotal)
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Electrical Block Libraries dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!