Constructing matrices in MATLAB -


i trying construct few matrices in matlab. programming not forte , cannot go this. know should nest loops, can't figure out how.i have array of data y t values. need set lag m , find tm=t-2m+1. matrices ymin , yplus have order m x tm, don't know how set them. in parentheses position of data in array. sorry format. matrices are:

      y(m)      y(m+1)   ...   y(t-m)       y(m-1)    y(m)     ...   y(t-m-1)          .         .         .        y(1)      y(2)    ...   y(tm) 

and

      y(m+1)    y(m+2)     ...   y(t-m+1)       y(m+2)    y(m+3)     ...   y(t-m-2)          .         .         .        y(2m)      y(2m+1)  ...   y(t) 

hope following matlab code can you!

%by mark 4/28/2015  clear all; %%%%%%%%%%%%%%%%% take example  m=4;  t=10; y=zeros(1,t);  i=1:(t)     y(i)=i; end  %%%%%%%%%%%%%%%%%%%%%% calculate ymin  count_i=0;  i=m:1:(t-m)      count_i=count_i+1;      count_j=0;      j=i:(-1):(i-m+1)         count_j=count_j+1;         ymin(count_j,count_i)=y(j);     end end  ymin  %%%%%%%%%%%%%%%%%%%%%% calculate ymax  count_i=0;  i=(m+1):1:(t-m+1)     count_i=count_i+1;     count_j=0;     j=i:1:(i+m-1)         count_j=count_j+1;         ymax(count_j,count_i)=y(j);     end end  ymax 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -