필터 지우기
필터 지우기

Loop syntax in matlab

조회 수: 1 (최근 30일)
Quantopic
Quantopic 2013년 5월 16일
Dear matlab users, I'm trying to implement a loop in matlab for estimating a markov-switching model; for instance, the code for the variable 1 is the following:
%Defining inputs
dep = JunkReturn1;
indep = [JunkSilliq1 Billiq TERM uTERM DEF uDEF rSP500 dVIXLeveragecorr];
k = 2;
S=[1 1 1 1 1 1 1 1 1];
advOpt.distrib = 'Normal';
advOpt.std_method=1;
%Estimating the model
[Spec_Out]=MS_Regress_Fit(dep,indep,k,S,advOpt);
This code works well, but, I've more than 100 variables, all of them are index-linked (e.g. JunkReturn1, JunkReturn2,...,JunkSilliq1, JunkSilliq2,...) and I want to speed the process up implementing a loop. I wrote the following code down to do that:
for i = 1:22
dep = JunkReturn(i);
indep = [JunkSilliq(i) Billiq TERM uTERM DEF uDEF rSP500 dVIXLeveragecorr];
k = 2;
S=[1 1 1 1 1 1 1 1 1];
advOpt.distrib = 'Normal';
advOpt.std_method=1;
[Spec_Out]=MS_Regress_Fit(dep,indep,k,S,advOpt);
end
but it does not work. Can someone of you tell me where I'm in wrong? Thanks everyone for helping!

답변 (1개)

Walter Roberson
Walter Roberson 2013년 5월 16일

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by