[simscape] how can I write a difference between output and input?

14 次查看(过去 30 天)
Hello all,
I've modelize a thermal component. my system put a heat flow Q at the node A. my component has to consume a part of this heat flow (Qcons) and i need to put out the rest of the heat flow at a node B.
the equation i want to put is B.Q == A.Q - Qcons
but i have an error :"Unexpected function or variable 'B'.
i have this in my variable: Q = { 0, 'J/s' };
and this in the fonction setup: through ( Q, A.Q, B.Q );
What can I do?
Thanks
  2 个评论
Babak
Babak 2012-11-28
Please post all your code. The error says that you have not defined B before using it. So MATLAB doesn't recognize it!
leclercq
leclercq 2012-11-29
thanks for your response
here is my code:
component Consomateur
% Consomateur
% Ce composant symbolise un consomateur de chaleur.
nodes
M = foundation.thermal.thermal; % :top
U = foundation.hydraulic.hydraulic; % :top
N = foundation.thermal.thermal; % :bottom
V = foundation.hydraulic.hydraulic; % :bottom
end
parameters
Cp = { 4180, 'J/(kg*K)' }; % Cp eau
rho = { 1000, 'kg/m^3' }; % rho de l'eau
Qcons = { 1000, 'J/s' }; % Puissance consommée
resistance = { 5000 'Pa/(m^3/s)' }; % resistance lineique consomateur
Tini = { 343.15, 'K' }; % Temperature initiale
pini = { 500000, 'Pa' }; % p initiale
end
variables
Q = { 0, 'J/s' };
q = { 0, 'm^3/s' };
p = { 0, 'Pa' };
T = { 0, 'K' };
end
function setup
through ( Q, M.Q, N.Q );
through ( q, U.q, V.q );
across ( p, U.p, V.p );
across ( T, M.T, N.T);
N.T = Tini;
U.p = pini;
end
equations
N.Q == M.Q - Qcons;
M.Q == q * rho * Cp * T;
p == resistance * q;
end
end
A and B of my example are transformed into N and M.
On my opinion, N.Q and M.Q are defined with through ( Q, M.Q, N.Q ) but i'me maybe wrong.

请先登录,再进行评论。

回答(1 个)

Babak
Babak 2012-11-30
M = foundation.thermal.thermal;
M is defined as an element of a structure. The structure names are fixed. I don't know if your M is also by itself a structure or not. But if it is then it might have its subelements like M.a and M.b
In your code we don't see how the foundation structure is fully defined. If it has an element like foundation.thermal.thermal.Q then M.Q would be meaningful, but if foundation.thermal.thermal.Q is not defined then M.Q is not defined either.
Now, you cannot change Q before calling M.Q. If structure M has an element named Q, it is a fixed name and you cannot change Q to
Q = { 0, 'J/s' };
or this Q doesn't have anything to do with the Q in M.Q

类别

Help CenterFile Exchange 中查找有关 Foundation and Custom Domains 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by