フィルターのクリア

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

1 回表示 (過去 30 日間)
Lahssan BEN TARLA
Lahssan BEN TARLA 2014 年 3 月 17 日
コメント済み: Mischa Kim 2014 年 3 月 17 日
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.
  3 件のコメント
Lahssan BEN TARLA
Lahssan BEN TARLA 2014 年 3 月 17 日
Regarding the output is a DEMUX I do?
Mischa Kim
Mischa Kim 2014 年 3 月 17 日
Same as above. You can use a DEMUX, or, return two output arguments:
function [U1 U2] = f(flux, teta); % U is the output current variable

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeString についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by