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!