Matlab Simulink Function Block

6 ビュー (過去 30 日間)
BILAL ASAD
BILAL ASAD 2018 年 8 月 23 日
コメント済み: BILAL ASAD 2018 年 8 月 24 日
Hi, I am trying to make a matrix using function. It works as a separate function but when I use it in Simulink Matlab Function block it gives error. Please help me to figure it out. Thanks in anticipation. Regards
function Induc = Lsrm(theta)
nb=27;
Nr=1;
Ns=30;
Lm=0.04;
for x=1:3
for y=1:nb
if x==1
L(x,y)=cos(theta+(2*(y-1)*pi/nb));
elseif x==2
L(x,y)=cos(theta+(4*pi/3)+(2*(y-1)*pi/nb));
else
L(x,y)=cos(theta+(2*pi/3)+(2*(y-1)*pi/nb));
end
end
end
Induc=((Nr/Ns)*Lm)*L;
end

採用された回答

Walter Roberson
Walter Roberson 2018 年 8 月 23 日
You need to initialize L to full size. Simulink arrays can only grow beyond their first assignment if they are specially built.
  1 件のコメント
BILAL ASAD
BILAL ASAD 2018 年 8 月 24 日
I initialize a zero matrix first, it works now for me. Thanks a lot

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by