please identify my mistake

l1=1;
for j=1:108
for t=2:108
if j<t
d2(l1,:)=c4*0;
else if j>=t
d2(l1,:)=c4*m1.a(1,2)^(j-1);
l1=l1+1;
end
end
end
end

4 件のコメント

Walter Roberson
Walter Roberson 2014 年 1 月 16 日
What error are you observing? Are you getting an error message, or is the result different than what you are expecting ?
arfa maqsood
arfa maqsood 2014 年 1 月 16 日
I am getting 'dimension mismatch' error
Walter Roberson
Walter Roberson 2014 年 1 月 16 日
Which line is the error occurring on?
Are you initializing d2 before the loop, or are you having d2 implicitly expanded as the loop runs?
arfa maqsood
arfa maqsood 2014 年 1 月 16 日
I initialize d2 by giving l1=1 before the loop. m1.a(1,2) is a scalar quantity stored by applying a time series model AR(1). I am writing a loop that is conditional too. c4 is a column vector of order 40018*1. I have to apply formula to first group of 374 observations in c4 and then to second group of 374 observations and so on. Basically it should generate a matrix of order 40018*108.

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 16 日

0 投票

  • instead of .
d2(l1,:)=c4*m1*a(1,2)^(j-1)

1 件のコメント

arfa maqsood
arfa maqsood 2014 年 1 月 16 日
m1.a(1,2) is a scalar quantity stored by applying a time series model AR(1). I am writing a loop that is conditional too. c4 is a column vector of some order. I have to apply formula to first group of observations in c4 and then to second group and so on.
Walter Roberson
Walter Roberson 2014 年 1 月 16 日

0 投票

In the case j < t, why are you not incrementing l1 ?

この質問は閉じられています。

タグ

質問済み:

2014 年 1 月 16 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by