how to convert a fichier.m to simulink blocks.?

1 次查看(过去 30 天)
hello i have this programme and i want convert it to block simulink.
_
function U=f(TE); % U is the output current variable
% TE is the input line vector
E=TE'; % E is the input column vector
flux=E(1); % input flux
teta=E(2); % input angle modulo pi/2
global TETAS TETAX TETAY TETAXY TETAON TETAOFF TETAQ V AUP BUP ADOWN BDOWN DL
LMIN LMAX
% if the teta value is situated between 0 and TETAX then the output is computed
% as flux/Lmin since during this interval the inductance is constant
if ((0 <= teta) & (teta <= TETAX))
U=[flux/LMIN,LMIN];
end;
% using the values computed in the initialization file int.m, we obtain for this
% interval the value of the current knowing the inductance equation
if ((TETAX < teta) & (teta <= TETAY))
U=[flux/((AUP*teta)+BUP),((AUP*teta)+BUP)];
end;
if ((TETAY < teta) & (teta <= TETAXY))
U=[flux/((ADOWN*teta)+BDOWN),((ADOWN*teta)+BDOWN)];
end;
if (teta >TETAXY)
U=[flux/LMIN,LMIN];
end;_

回答(1 个)

Mischa Kim
Mischa Kim 2014-3-17
编辑:Mischa Kim 2014-3-17
Lahssan, you can simply use a MATLAB Function block (in: Simulink library > User-Defined Functions), open the block and paste the code as is. In earlier releases the block might have been named: Embedded MATLAB Function.
If your function has more, say for example, two inputs you can use a MUX (multiplexer) block to combine them into one input. Alternatively, you could rewrite your function definition as
function U = f(flux, teta); % U is the output current variable
which will automatically generate two inputs at the block.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by