Arrays have incompatible sizes for this operation.
1 view (last 30 days)
Show older comments
Abdullah Alsayegh
on 21 Apr 2022
Edited: Walter Roberson
on 21 Apr 2022
I am trying to plot my graph for 4 given values in one graph for this matlab code.
format long
% Given Values
T = 429.65; % K - Given Temperture
P = 99.6 ; % kPa - Pressure
% Specific Diameters given
Dp1 = 0.01:0.01:10;
Dp = Dp1 * 10^-6;
%Actual particle Density given.
Pp = 1260; % kg/m^3
% Standard Temperture and Mu at SATP
Ts0 = 298.15; % K
Ts = 110.4; % K
Rair = 0.287; % kJ / kg * K
Mu_s = 1.849*10^-5; % kg/m*s
g = 9.81;
% Calculate Air Density
Pa = P / (Rair * T);
Mu = Mu_s * (T/Ts0)^(3/2) * (Ts0+Ts)/(T+Ts);
% lamda - Mean free path
lamda1 = (Mu/0.499) * sqrt(pi/(8*Pa*P*1000)); % Unit m
lamda = lamda1 *10^6; % Unit Mu*m
% Knudsen number
Kn = lamda1 ./ Dp;
% Cunningham Correction Factor
C = 1 + Kn .* (2.514+0.80.*exp(-0.55./Kn));
% -----------------------------------------------------------------
% Given
Df = [5, 10, 15, 20] *10^-6; % Given in microns change to m
U0 = 0.225; % m/s
e = 0.875; % fraction
L = 0.00335; % m
%intial
Kb = 1.381*10^-23
% Calvert & Englund
Stk = ((Pp-Pa).*Dp.^2.*(U0./e)) ./ (18.*Mu.*Df)
nfDpCE = ((Stk)./(Stk+0.425)).^2
%Cheng
Dap = (Kb.*T.*C)./ (3.*pi.*Mu.*Dp)
alpha = 1 - e;
Kk = -0.5.*log(alpha)+alpha-0.25.*alpha.^2-0.75
Pe = (Df.*U0)./(Dap)
nfDpCheng = 2.92 .* ((1-alpha)./Kk).^(1./3).*Pe.^(-2./3);
nfDp = nfDpCE + nfDpCheng
Lc = (pi./4).*(e./(1-e)).*(Df./nfDp)
nDp = (1 - exp(-L./Lc) )*100
% ========================================================================
Dp2= log(Dp1*10^1);
plot(Dp2,nDp)
This error shows up and I couldn't be able to fix it can you please assist me on this, thank you
Arrays have incompatible sizes for this operation.
Error in HW14Q2 (line 45)
Stk = ((Pp-Pa).*Dp.^2.*(U0./e)) ./ (18.*Mu.*Df)
0 Comments
Accepted Answer
Walter Roberson
on 21 Apr 2022
format long
% Given Values
T = 429.65; % K - Given Temperture
P = 99.6 ; % kPa - Pressure
% Specific Diameters given
Dp1 = 0.01:0.01:10;
Dp = Dp1 * 10^-6;
%Actual particle Density given.
Pp = 1260; % kg/m^3
% Standard Temperture and Mu at SATP
Ts0 = 298.15; % K
Ts = 110.4; % K
Rair = 0.287; % kJ / kg * K
Mu_s = 1.849*10^-5; % kg/m*s
g = 9.81;
% Calculate Air Density
Pa = P / (Rair * T);
Mu = Mu_s * (T/Ts0)^(3/2) * (Ts0+Ts)/(T+Ts);
% lamda - Mean free path
lamda1 = (Mu/0.499) * sqrt(pi/(8*Pa*P*1000)); % Unit m
lamda = lamda1 *10^6; % Unit Mu*m
% Knudsen number
Kn = lamda1 ./ Dp;
% Cunningham Correction Factor
C = 1 + Kn .* (2.514+0.80.*exp(-0.55./Kn));
% -----------------------------------------------------------------
% Given
Df = [5, 10, 15, 20] *10^-6; % Given in microns change to m
U0 = 0.225; % m/s
e = 0.875; % fraction
L = 0.00335; % m
%intial
Kb = 1.381*10^-23
% Calvert & Englund
whos
Stk = ((Pp-Pa).*Dp.^2.*(U0./e)) ./ (18.*Mu.*Df)
Dp is 1 x 1000, but Df is 1 x 4, so you are dividing a 1 x 1000 element-wise by a 1 x 4.
1 Comment
Walter Roberson
on 21 Apr 2022
Edited: Walter Roberson
on 21 Apr 2022
If you want each Df in combination with each Dp then
format long
% Given Values
T = 429.65; % K - Given Temperture
P = 99.6 ; % kPa - Pressure
% Specific Diameters given
Dp1 = 0.01:0.01:10;
Dp = Dp1 * 10^-6;
%Actual particle Density given.
Pp = 1260; % kg/m^3
% Standard Temperture and Mu at SATP
Ts0 = 298.15; % K
Ts = 110.4; % K
Rair = 0.287; % kJ / kg * K
Mu_s = 1.849*10^-5; % kg/m*s
g = 9.81;
% Calculate Air Density
Pa = P / (Rair * T);
Mu = Mu_s * (T/Ts0)^(3/2) * (Ts0+Ts)/(T+Ts);
% lamda - Mean free path
lamda1 = (Mu/0.499) * sqrt(pi/(8*Pa*P*1000)); % Unit m
lamda = lamda1 *10^6; % Unit Mu*m
% Knudsen number
Kn = lamda1 ./ Dp;
% Cunningham Correction Factor
C = 1 + Kn .* (2.514+0.80.*exp(-0.55./Kn));
% -----------------------------------------------------------------
% Given
Df = [5, 10, 15, 20].' *10^-6; % Given in microns change to m
U0 = 0.225; % m/s
e = 0.875; % fraction
L = 0.00335; % m
%intial
Kb = 1.381*10^-23;
% Calvert & Englund
Stk = ((Pp-Pa).*Dp.^2.*(U0./e)) ./ (18.*Mu.*Df);
nfDpCE = ((Stk)./(Stk+0.425)).^2;
%Cheng
Dap = (Kb.*T.*C)./ (3.*pi.*Mu.*Dp);
alpha = 1 - e;
Kk = -0.5.*log(alpha)+alpha-0.25.*alpha.^2-0.75;
Pe = (Df.*U0)./(Dap);
nfDpCheng = 2.92 .* ((1-alpha)./Kk).^(1./3).*Pe.^(-2./3);
nfDp = nfDpCE + nfDpCheng;
Lc = (pi./4).*(e./(1-e)).*(Df./nfDp);
nDp = (1 - exp(-L./Lc) )*100;
% ========================================================================
Dp2= log(Dp1*10^1);
plot(Dp2,nDp)
legend(string(Df))
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!