How to plot 2 functions into one plot

조회 수: 6 (최근 30일)
Mason Condren
Mason Condren 2023년 2월 16일
편집: Torsten 2023년 2월 16일
Here below is my code, I am trying to get Q1 and Q2 to show up on the same plot while differentiating between the two. The graph should look like the one attached.
=============================================================================================================
% density
p = 1.009;
%dynamic visc
mew = 3.09e-5;
%width
w = 0.022;
%delta Pressure
delP = 31.1;
cp = 1008;
k = 0.02953;
Pr = 0.7154;
%kinematic visc
v = 2.097e-5;
%t optimal
t = 0.001011;
L = 0.022;
%L_opt
H = 0.022477;
%buoyancy
B = (1/350);
%alpha
a = 2.931e-5;
syms D;
eqn = (1/12)*(1/mew)*p^(4/3)*D^3*w^(-4/3)*delP^(2/3)*cp == 1.20818*k*Pr^(1/3)*v^(-2/3)*((D+t)/(L+t))^(1/3)*L^(1/3)
D_opt = vpasolve(eqn,D)
Q1 = ((L+t)/(D+t))*((p*B*9.81*w*cp*(134-20)^2*D^3)/(12*v));
Q2 = 1.034*k*w*(134-20)*((1/(a*v))*B*9.81*H^3*(134-20)^(1/4)*((L+t)/(D+t)));
fplot(Q1)
fplot(Q2)
=============================================================================================================
  댓글 수: 1
Torsten
Torsten 2023년 2월 16일
편집: Torsten 2023년 2월 16일
Why do you solve eqn for D if you nowhere use the result D_opt ?

댓글을 달려면 로그인하십시오.

채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 16일
Here is a code that shows the plot figure similar to the assignment:
% density
p = 1.009;
%dynamic visc
mew = 3.09e-5;
%width
w = 0.022;
%delta Pressure
delP = 31.1;
cp = 1008;
k = 0.02953;
Pr = 0.7154;
%kinematic visc
v = 2.097e-5;
%t optimal
t = 0.001011;
L = 0.022;
%L_opt
H = 0.022477;
%buoyancy
B = (1/350);
%alpha
a = 2.931e-5;
syms D;
eqn = (1/12)*(1/mew)*p^(4/3)*D^3*w^(-4/3)*delP^(2/3)*cp == 1.20818*k*Pr^(1/3)*v^(-2/3)*((D+t)/(L+t))^(1/3)*L^(1/3)
eqn = 
D_opt = vpasolve(eqn,D);
Q1 = ((L+t)/(D+t))*((p*B*9.81*w*cp*(134-20)^2*D^3)/(12*v));
Q2 = 1.034*k*w*(134-20)*((1/(a*v))*B*9.81*H^3*(134-20)^(1/4)*((L+t)/(D+t)));
fplot(Q1, 'r-', 'linewidth', 2);
hold on
fplot(Q2, 'b-', 'linewidth', 2);
xlim([0 0.025]),
ylim([-50, 500]),shg
grid on
xlabel('D, [mm]')
ylabel('Heat Transfer, [W]')
  댓글 수: 2
Mason Condren
Mason Condren 2023년 2월 16일
Thank you!!
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 16일
Most welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by