Expired coding question, don't refer to this

2 次查看(过去 30 天)
Hi,
This code is not valid, solution found a different way.
figure(1)
qdot=(-2500:1:250);
Tout=qdot./7.63358+2669.85./7.63358;
plot(qdot,Tout);
title('Tout vs qdot')
xlabel('qdot')
ylabel('Tout')
figure(2)
qout=(-2500:1:250);
Tout1=-((qout.*2.5.*10.^(-4))./(0.558.*0.02)-307.15);
plot(qout,Tout1);
title('Tout vs qout')
xlabel('qout')
ylabel('Tout')
syms qout qdot
eqn = Tout == Tout1;
solve (eqn,qdot,qout)

回答(1 个)

Florian Bidaud
Florian Bidaud 2024-3-4
编辑:Florian Bidaud 2024-3-4
You haven't defined Tout and Tout1 as equations but as numerical variables because qout and qdot are int arrays. You should first declare qout and qdot as syms before defining Tout and Tout1
syms qout qdot
Tout=qdot./7.63358+2669.85./7.63358;
Tout1=-((qout.*2.5.*10.^(-4))./(0.558.*0.02)-307.15);
eqn = Tout == Tout1;
s=solve (eqn,qdot,qout);
disp(s)
qdot: -16102921157410571293520415132337/49517601571415210995964968960 qout: 0
figure(1)
qdot=(-2500:1:250);
Tout=qdot./7.63358+2669.85./7.63358;
plot(qdot,Tout);
title('Tout vs qdot')
xlabel('qdot')
ylabel('Tout')
figure(2)
qout=(-2500:1:250);
Tout1=-((qout.*2.5.*10.^(-4))./(0.558.*0.02)-307.15);
plot(qout,Tout1);
title('Tout vs qout')
xlabel('qout')
ylabel('Tout')
  1 个评论
John D'Errico
John D'Errico 2024-3-4
编辑:John D'Errico 2024-3-4
This answer is good as a start, but not complete I would suggest. I think it did not go far enough. It is also the case there is no single, unique solution.
syms qout qdot
Tout=qdot./7.63358+2669.85./7.63358;
Tout1=-((qout.*2.5.*10.^(-4))./(0.558.*0.02)-307.15);
I'll show the relation reduced to short digits to make it more readable.
vpa(Tout == Tout1,4)
ans = 
As you can see, there is a linear relation between the two unknowns qdot and qout. Choose ANY value for one of them, and the other is given directly by a linear equation, a straight line.
We could even have MATLAB return the functional relationship itself, thus
qdotsol = solve(Tout == Tout1,qdot)
qdotsol = 
As a simple functional relationship, we see the dependence between the two.
vpa(qdotsol,4)
ans = 
Choose any value for qout, and you can compute qdot directly. And that is what I think the answer from @Florian Bidaud should have pointed out. We can see the relationship in the plot below:
fplot(qdotsol,[-2500,250])
xlabel qout
ylabel qdot
grid on
So ANY point on the straight line plot is a solution that makes the pair of expressions Tout and Tout1 equal.

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by