Unable to plot all lines on the same graph

2 次查看(过去 30 天)
I have written my equations with no error messages, and for some reason when it comes to plotting the graph I am only able to plot a couple of the lines ( when the code is ran).
% Constants
% ceiling
R1 = 0.01126172832; % Value of resistance R1
R2 = 0.3449615264; % Value of resistance R2
R3 = 3.642793719*10^-6; % Value of resistance R3
C1 = 54551.538; % Value of capacitance C1
C2 = 14220.95348; % Value of capacitance C2
C3 = 25734.0951; % Value of capacitance C3
Q_ceiling = 131.6056667;
%floor
R4 = 0.01070907326; % Value of resistance R4
R5 = 0.1640164882; % Value of resistance R5
R6 = 3.464028232*10^-6; % Value of resistance R6
C4 = 57366.738; % Value of capacitance C4
C5 = 7477.421738; % Value of capacitance C5
C6 = 27062.1351; % Value of capacitance C6
Q_floor = 138.3973924; % Value of Q
% wall with window
R7 = 0.0104376743; % Value of resistance R7
R8 = 0.3197196698; % Value of resistance R8
R9 = 3.376239713*10^-6; % Value of resistance R9
C7 = 58858.38; % Value of capacitance C7
C8 = 15343.69725; % Value of capacitance C8
C9 = 27765.801; % Value of capacitance C9
Q_windowwall = 141.9970071; % Value of Qwindowwall
%sidewall
R10 = 9.367616659*10^-3; % Value of resistance R10
R11 = 0.2869423992; % Value of resistance R11
R12 = 3.030111735*10^-6; % Value of resistance R12
C10 = 65581.74; % Value of capacitance C10
C11 = 17096.39925; % Value of capacitance C11
C12 = 30937.473; % Value of capacitance C12
Q_sidewall = 158.2172462; % Value of Qsidewall
% BH
R13 = 0.01992037022; % Value of resistance R13
R14 = 0.610187098 ; % Value of resistance R14
R15 = 0.01610893939; % Value of resistance R15
C13 = 30840.0192; % Value of capacitance C13
C14 = 8039.63544; % Value of capacitance C14
C15 = 15686.66403; % Value of capacitance C15
Q_BH = 74.0135789; % Value of QBH
% REAR DOORS
R16 = 0.02676244689; % Value of resistance R16
R17 = 0.8197688908; % Value of resistance R17
R18 = 8.656759486*10^-6; % Value of resistance R18
C16 = 22955.472; % Value of capacitance C16
C17 = 5984.2254; % Value of capacitance C17
C18 = 10828.9944; % Value of capacitance C18
Q_doors = 55.38053069; % Value of QDOORS
% Time vector for a 2-hour period (in seconds)
t = 0:0.01:2 *3600;
% Calculation of ∆T1_ceiling
deltaT1_ceiling = R1*Q_ceiling*(1 - exp(-1/(R1*C1)*t)) + R2*Q_ceiling*(1 - exp(-1/(R2*C2)*t)) + R3*Q_ceiling*(1 - exp(-1/(R3*C3)*t));
% Calculation of ∆T1_floor
deltaT1_floor= R4*Q_floor*(1 - exp(-1/(R4*C4)*t)) + R5*Q_floor*(1 - exp(-1/(R5*C5)*t)) + R6*Q_windowwall*(1 - exp(-1/(R6*C6)*t));
% Calculation of ∆T1_windowwall
deltaT1_windowwall= R7*Q_windowwall*(1 - exp(-1/(R7*C7)*t)) + R8*Q_windowwall*(1 - exp(-1/(R8*C8)*t)) + R9*Q_windowwall*(1 - exp(-1/(R9*C9)*t));
%Calculation of ∆T1_sidewall
deltaT1_sidewall= R10*Q_sidewall*(1 - exp(-1/(R10*C10)*t)) + R11*Q_sidewall*(1 - exp(-1/(R11*C11)*t)) + R12*Q_sidewall*(1 - exp(-1/(R12*C12)*t));
%Calculation of ∆T1_BH
deltaT1_BH= R13*Q_BH*(1 - exp(-1/(R13*C13)*t)) + R14*Q_BH*(1 - exp(-1/(R14*C14)*t)) + R15*Q_BH*(1 - exp(-1/(R15*C15)*t));
% Calculation of ∆T1_DOORS
deltaT1_doors= R16*Q_doors*(1 - exp(-1/(R16*C16)*t)) + R17*Q_doors*(1 - exp(-1/(R17*C17)*t)) + R18*Q_doors*(1 - exp(-1/(R18*C18)*t));
% Convert time to hours for plotting
t_hours = t / 3600; % Convert time from seconds to hours
%plotting
plot(t_hours, deltaT1_ceiling);
hold on;
plot(t_hours, deltaT1_sidewall);
plot(t_hours, deltaT1_doors);
plot(t_hours, deltaT1_BH);
plot(t_hours, deltaT1_windowwall);
plot(t_hours, deltaT1_floor);
hold off;

回答(1 个)

Cris LaPierre
Cris LaPierre 2024-4-29
They are all there. It's just that plots 1, 2, 3, and 5 all exactly overlap, so it makes them look like a single line.
% Constants
% ceiling
R1 = 0.01126172832; % Value of resistance R1
R2 = 0.3449615264; % Value of resistance R2
R3 = 3.642793719*10^-6; % Value of resistance R3
C1 = 54551.538; % Value of capacitance C1
C2 = 14220.95348; % Value of capacitance C2
C3 = 25734.0951; % Value of capacitance C3
Q_ceiling = 131.6056667;
%floor
R4 = 0.01070907326; % Value of resistance R4
R5 = 0.1640164882; % Value of resistance R5
R6 = 3.464028232*10^-6; % Value of resistance R6
C4 = 57366.738; % Value of capacitance C4
C5 = 7477.421738; % Value of capacitance C5
C6 = 27062.1351; % Value of capacitance C6
Q_floor = 138.3973924; % Value of Q
% wall with window
R7 = 0.0104376743; % Value of resistance R7
R8 = 0.3197196698; % Value of resistance R8
R9 = 3.376239713*10^-6; % Value of resistance R9
C7 = 58858.38; % Value of capacitance C7
C8 = 15343.69725; % Value of capacitance C8
C9 = 27765.801; % Value of capacitance C9
Q_windowwall = 141.9970071; % Value of Qwindowwall
%sidewall
R10 = 9.367616659*10^-3; % Value of resistance R10
R11 = 0.2869423992; % Value of resistance R11
R12 = 3.030111735*10^-6; % Value of resistance R12
C10 = 65581.74; % Value of capacitance C10
C11 = 17096.39925; % Value of capacitance C11
C12 = 30937.473; % Value of capacitance C12
Q_sidewall = 158.2172462; % Value of Qsidewall
% BH
R13 = 0.01992037022; % Value of resistance R13
R14 = 0.610187098 ; % Value of resistance R14
R15 = 0.01610893939; % Value of resistance R15
C13 = 30840.0192; % Value of capacitance C13
C14 = 8039.63544; % Value of capacitance C14
C15 = 15686.66403; % Value of capacitance C15
Q_BH = 74.0135789; % Value of QBH
% REAR DOORS
R16 = 0.02676244689; % Value of resistance R16
R17 = 0.8197688908; % Value of resistance R17
R18 = 8.656759486*10^-6; % Value of resistance R18
C16 = 22955.472; % Value of capacitance C16
C17 = 5984.2254; % Value of capacitance C17
C18 = 10828.9944; % Value of capacitance C18
Q_doors = 55.38053069; % Value of QDOORS
% Time vector for a 2-hour period (in seconds)
t = 0:0.01:2 *3600;
% Calculation of ∆T1_ceiling
deltaT1_ceiling = R1*Q_ceiling*(1 - exp(-1/(R1*C1)*t)) + R2*Q_ceiling*(1 - exp(-1/(R2*C2)*t)) + R3*Q_ceiling*(1 - exp(-1/(R3*C3)*t));
% Calculation of ∆T1_floor
deltaT1_floor= R4*Q_floor*(1 - exp(-1/(R4*C4)*t)) + R5*Q_floor*(1 - exp(-1/(R5*C5)*t)) + R6*Q_windowwall*(1 - exp(-1/(R6*C6)*t));
% Calculation of ∆T1_windowwall
deltaT1_windowwall= R7*Q_windowwall*(1 - exp(-1/(R7*C7)*t)) + R8*Q_windowwall*(1 - exp(-1/(R8*C8)*t)) + R9*Q_windowwall*(1 - exp(-1/(R9*C9)*t));
%Calculation of ∆T1_sidewall
deltaT1_sidewall= R10*Q_sidewall*(1 - exp(-1/(R10*C10)*t)) + R11*Q_sidewall*(1 - exp(-1/(R11*C11)*t)) + R12*Q_sidewall*(1 - exp(-1/(R12*C12)*t));
%Calculation of ∆T1_BH
deltaT1_BH= R13*Q_BH*(1 - exp(-1/(R13*C13)*t)) + R14*Q_BH*(1 - exp(-1/(R14*C14)*t)) + R15*Q_BH*(1 - exp(-1/(R15*C15)*t));
% Calculation of ∆T1_DOORS
deltaT1_doors= R16*Q_doors*(1 - exp(-1/(R16*C16)*t)) + R17*Q_doors*(1 - exp(-1/(R17*C17)*t)) + R18*Q_doors*(1 - exp(-1/(R18*C18)*t));
% Convert time to hours for plotting
t_hours = t / 3600; % Convert time from seconds to hours
%plotting
plot(t_hours, deltaT1_ceiling);
hold on;
plot(t_hours, deltaT1_sidewall);
plot(t_hours, deltaT1_doors);
plot(t_hours, deltaT1_BH);
plot(t_hours, deltaT1_windowwall);
plot(t_hours, deltaT1_floor);
hold off;
legend(["Ceiling","Sidewall","Doors","BH","Windowwall","floor"])
  3 个评论
Cris LaPierre
Cris LaPierre 2024-4-29
It's possible, though it will be challenging to make it clear there are 4 overlapping lines. Explore the formatting options available, including line width. You might need to manually set the colors so that it is easier to distinguish the different lines.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by