How can I solve different equations that depend on different changing values?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I'm trying to solve multiple equations, some depend on others. In this case s, A_t, and n_o depend on N. N should be changing in intervals of 1 from 3-10, which I did a FOR loop as n=3:10. Also, t depends on s which changes depending on the N and other equations depend on t. I'm not getting the right answers which I know because I solved the problem by hand and compared it with other person (who solved it using Python). I'm trying to plot q_f vs N, T_b vs N but I can't do so because I'm not getting the correct values.
I'm stuck and I don't know where I made a mistake.Thank you!!!
w = 0.02; % Width of Chip, in meters
lst = zeros(1, 8);
apx = zeros(1, 8);
dtr = zeros(1,8);
fgh = zeros(1,8);
for n = 3:10
i = n - 2;
[x, y, z, b] = example_fun(n, w);
lst(i) = x;
apx(i) = y;
dtr(i) = z;
fgh(i) = b;
end
disp(lst);
disp(apx);
disp(dtr);
disp(fgh);
function [q_f, q_c, T_b, T_tip] = example_fun(N, w)
k = 180; % W/(m*K)
Lb = 0.003; % Base thickness, in meters
Lf = 0.012; % Fin length, in meters
T_infinity = 20; % degree C
T_chip = 85; % degree C
h = 100; % Convection coefficient W/(m^2*K)
A_b = w^2; % Area of Base
Rt_cont = 0.00002/(A_b); % Contact Resistance (K/W)
s = (w + 2)/N; % Spacing between Fins
t = s - 2; % Thickeness of Fins
P = 2*w + 2*t; % Perimeter of Fin, in meters
A_f = 2*w*Lf; % Area of Fin, in meters
A_t = N*A_f + (w^2) - (N*w*t); % Total Area
A_c = w*t; % Cross sectional Area
Rt_cond = Lb/(k*A_b); % Conduction Resistance (K/W)
m = sqrt((h*P)/(k*A_c));
n_f = tanh(m*Lf)/(m*Lf); % Fin Efficiency
n_o = 1-((N*A_f)*(1-n_f))/(A_t); % Overrall Efficiency
Rt_f = 1/(n_o*h*A_t); % Fin Resistance
Req = Rt_cont + Rt_cond + Rt_f; % Total Resistance
q_c = (T_chip - T_infinity)/Req; % Heat Transfer Rate of Chip
T_b = T_infinity + (q_c*Rt_f); % Temperature at the base, degrees C
T_tip = T_infinity + ((T_b - T_infinity)*(1/(cosh(m*Lf)))); % Temperature at the Tip
M = sqrt(h*P*k*A_c)*(T_b*T_infinity)*tanh(m*Lf);
q_f = M*tanh(m*Lf); % Heat Transfer Rate of Fin
end
Answers (1)
Star Strider
on 28 Feb 2019
As far as plotting them, this seems to work:
w = 0.02; % Width of Chip, in meters
lst = zeros(1, 8);
apx = zeros(1, 8);
dtr = zeros(1,8);
fgh = zeros(1,8);
for n = 3:10
i = n - 2;
[x, y, z, b] = example_fun(n, w);
lst(i) = x;
apx(i) = y;
dtr(i) = z;
fgh(i) = b;
end
disp(lst);
disp(apx);
disp(dtr);
disp(fgh);
nv = 3:10;
figure
plot(nv, lst)
grid
xlabel('N')
ylabel('q_f')
figure
plot(nv, dtr)
grid
xlabel('N')
ylabel('T_b')
Experiment to get the result you want.
2 Comments
Stephanie Roman
on 28 Feb 2019
Star Strider
on 28 Feb 2019
You need to do element-wise multiplication and division (exponentiation may also be required, however you do not do any exponentiation here). That uses the ‘dot operator’, so .* instead of *, ./ instead of /, and .^ instead of ^.
This works:
h = 1;
w = 0.02;
k = 180; % W/(m*K)
Lb = 0.003; % Base thickness, in meters
Lf = 0.012; % Fin length, in meters
T_infinity = 20; % degree C
T_chip = 85; % degree C
A_b = w^2; % Area of Base
Rt_cont = 0.00002/(A_b); % Contact Resistance (K/W)
N = [3,4,5,6,7,8,9,10];
s = (w + 2)./N; % Spacing between Fins
t = s - 2; % Thickeness of Fins
P = 2*w + 2*t; % Perimeter of Fin, in meters
A_f = 2*w*Lf; % Area of Fin, in meters
A_t = N*A_f + (w^2) - (N*w.*t); % Total Area
A_c = w*t; % Cross sectional Area
Rt_cond = Lb/(k*A_b); % Conduction Resistance (K/W)
m = sqrt((h*P)./(k*A_c));
n_f = tanh(m*Lf)./(m*Lf); % Fin Efficiency
n_o = 1-((N*A_f).*(1-n_f))./(A_t); % Overrall Efficiency
Rt_f = 1./(n_o*h.*A_t); % Fin Resistance
Req = Rt_cont + Rt_cond + Rt_f; % Total Resistance
q_c = (T_chip - T_infinity)./Req; %
T_b = T_infinity + (q_c.*Rt_f);
T_tip = T_infinity + ((T_b - T_infinity).*(1./(cosh(m*Lf))));
M = sqrt(h*P*k.*A_c).*(T_b*T_infinity).*tanh(
m*Lf);
q_f = M.*tanh(m*Lf);
You did not supply a value fo ‘h’, so I created one.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!