How to store data in a for loop

4 ビュー (過去 30 日間)
Khoo Wei Yang
Khoo Wei Yang 2021 年 3 月 17 日
回答済み: ANKUR KUMAR 2021 年 3 月 17 日
for i=1:100
trainin = x(:,tr.trainInd);
trainTarg1= t(:,tr.trainInd);
trainout = sim(net,trainin);
[m1,b1,r1]=postreg(trainout,trainTarg1);
end
So this is training for the neural network, and i need to get the r1 value for each loop. How do i do this?

採用された回答

ANKUR KUMAR
ANKUR KUMAR 2021 年 3 月 17 日
If you wish to save into cell, then you can use:
for i=1:100
trainin = x(:,tr.trainInd);
trainTarg1= t(:,tr.trainInd);
trainout = sim(net,trainin);
[m1,b1,r1{i}]=postreg(trainout,trainTarg1);
end
If r1 is 1D array, you can save in 2d array:
for i=1:100
trainin = x(:,tr.trainInd);
trainTarg1= t(:,tr.trainInd);
trainout = sim(net,trainin);
[m1,b1,r1(:,i)]=postreg(trainout,trainTarg1);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by