I have some code which is running regressions,
I got some great code on stack overflow, yesterday, which helps to insert the x variables.
%My attempt a Minimal, Complete, and Verifiable example
clear;
% K: horizon
Myarbitrarycombinations= [7 8; 7 4;];
for ii=size(Myarbitrarycombinations,1)
for j = [1, 2, 3];
K=j;
Myarbitrarycombinations(ii,1)
Myarbitrarycombinations(ii,2)
end
end
The problem I am having is with the "K" for loop, in the above code.
The code is returning
K=1, 7 4
K=2, 7 4
K=3, 7 4
However, I would like it to return,
K=1, 7 4
K=2, 7 4
K=3, 7 4
and
K=1, 7 8
K=2, 7 8
K=3, 7 8
Your problem is in this for
loop:
for ii=size(Myarbitrarycombinations,1)
size(...,1)
is a scalar (2). This is the same as
for ii=2
meaning that it iterates only once. Instead, do:
for ii=1:size(Myarbitrarycombinations,1)
% ^^^
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.