how to remove the error showing undefined function or variable

hello, i am using function block in matlab simulation .in that want to generate matrix X1 from matrix A
for j1=1:k2
for j2=1:m1
for j3=1:n1
X1(m1*(j1-1)+j2,j3)=A(j2,j3);
end
end
end
but executing code am getting error....
Undefined function or variable 'X1'. The first assignment to a local variable determines its class.
Function 'Subsystem9/Mtesting' (#53.2154.2156), line 66, column 16:
"X1"
Launch diagnostic report.

 採用された回答

David Hill
David Hill 2019 年 9 月 21 日

0 投票

Preallocate X1 before the loop.
X1=zeros(m1*k2,n1);

1 件のコメント

ram kumar
ram kumar 2019 年 9 月 21 日
thankyou.
but in this simulation again facing on more error
Errors occurred during parsing of MATLAB function
any suggestion to remove it.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2019 年 9 月 21 日

コメント済み:

2019 年 9 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by