how to convert a fichier.m to simulink blocks.?
2 次查看(过去 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;_
0 个评论
回答(1 个)
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 个评论
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!