Simultaneous Equations Using MATLAB Function Block in Simulink

Hi all,
I suspect this may be a very basic question, however I am very new to the software and am trying my best to battle through by trial and error and helpful advice found on this website.
I have three equations containing three unknown. This is how I have inputted into the MATLAB workspace inside the MATLAB function block of Simulink:
function [qdot,Tpo,Tso] = fcn(mdotp,Cpp,Tpi,mdots,Cps,Tsi,U,A,f)
%#codegen
qdot = U*A*f*((Tpo-Tso)-(Tpi-Tsi))/log((Tpo-Tso)/(Tpi-Tsi))
qdot = mdotp*Cpp*(Tpi-Tpo)
qdot = mdots*Cps*(Tso-Tsi)
Where; qdot, Tpo, Tso are the unknowns I want as outputs from the Simulink block
and; mdotp, Cpp, Tpi, mdots, Cps, Tsi, U, A, f are known input into the Simulink block
Unfortunately when I run the simulation, a whole host of error is spewed out.
I would be forever grateful if someone can help me. Very much left scratching my head!
Regards Andy

 채택된 답변

TAB
TAB 2012년 1월 9일

0 개 추천

  1. Tpo and Tso are used for calculating qdot without defining and initializing them first.
  2. Tpo and Tso are outputs from the function but they are never returned.From the program it seems that you are treating then as input.
  3. Also you are overwritting qdot in 3 statements. (It may generate warning).

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Model Verification에 대해 자세히 알아보기

질문:

2012년 1월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by