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

조회 수: 16 (최근 30일)
leclercq
leclercq 2012년 11월 28일
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