Extracting a result of a looped finction from the workspace

조회 수: 1 (최근 30일)
Adam Kepinski
Adam Kepinski 2018년 3월 2일
댓글: Adam Kepinski 2018년 3월 2일
Hi,
I ran a lagged regression 60 times and I got the coefficients printed in the command window (picture is attached). I'm stuck trying to extract one same cell from every table (row 2, column 3) into one array.
This is the function used to obtain tables: tmp = table2array(mdl.Coefficients)
Any help would be appreciated.
  댓글 수: 2
KL
KL 2018년 3월 2일
Your attachment is not quite useful. It would be helpful if you give an example of what you have and what you want to have.
Adam Kepinski
Adam Kepinski 2018년 3월 2일
Thanks for the answer. I managed to narrow down the printed data into the output i'm looking for (tstat). But still struggle to put it into an array. Maybe this screenshot will be more informative.
Issue is that I am getting an array in workspace with only one "tmp".

댓글을 달려면 로그인하십시오.

채택된 답변

KL
KL 2018년 3월 2일
편집: KL 2018년 3월 2일
You're replacing the value of tmp during every iteration. Pre-allocate tmp with a proper size and store every iteration at its respective index.
For example, before you start the loop declare tmp
tmp = zeros(h,1);
and then inside the loop replace your last line with,
tmp(c,1) = mdl.Coefficients(2,3);
P.S: attaching screenshots don't help much. Just copy paste your code here and format it using {} Code button.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by