Time series syntax question

조회 수: 2 (최근 30일)
Stefan
Stefan 2014년 11월 26일
답변: Image Analyst 2014년 11월 26일
Hi everyone, I'm using a template for a homework assignment in MATLAB. I'm having trouble with a section that seems to require time series, but I can't find any info on this particular type. The code is: ts(i,1) =%fill in here . I've never seen the ts(i,1) syntax before, and can't find any info on it anywhere. Can anyone explain to me what this means?
  댓글 수: 2
per isakson
per isakson 2014년 11월 26일
Did you read this? Looks like a starting point to me.
Stefan
Stefan 2014년 11월 26일
I read these, but none of them go over this syntax, unless I just don't recognize it, which is also very likely.

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

채택된 답변

Image Analyst
Image Analyst 2014년 11월 26일
ts(i, 1) refers to the element of the ts array in the i'th row and the first column. Assuming i is a single number , like 5 or whatever, then ts(i,1) would be assigned a single number, like 73 or whatever.
ts(i, 1) = 73;
If i = 5, this would assign ts(5,1) a value of 73.
If i is an array of numbers or array of logicals then ts(i,1) would assign a bunch of rows in the first column. Like if i were [2,4,8], ts(i,1) would need to take 3 numbers, like
ts(i, 1) = [22,34,88];
This would assign element ts(2,1) to 22, element ts(4,1) to 34, and assign element ts(8,1) to 88. I hope that explains it better.

추가 답변 (1개)

Youssef  Khmou
Youssef Khmou 2014년 11월 26일
ts(i,1) means performing calculation of the elements of first column of matrix ts, ts(i,2) means the ith element on the second column, ( use other variable instead of i, i is the imaginary number )
  댓글 수: 2
Stefan
Stefan 2014년 11월 26일
편집: per isakson 2014년 11월 26일
So what would I even put after the equals sign? I'm still confused. This is the rest of the code leading up to that point, if this helps any:
function out = main()
close all;
pars=[4 10 1 20 1 20];
k1=pars(1);
k2=pars(2);
k3=pars(3);
k4=pars(4);
k5=pars(5);
k6=pars(6);
init=[10 10 10];
steps = 500000;
ts= zeros(steps+1,4);
ts(1,2:4) = init;
a=ts(1,2);
b=ts(1,3);
c=ts(1,4);
for i = 2:(steps+1)
lmd1 = k1*a*b;
lmd2 = c*k2;
lmd3 = a*k3;
lmd4 = k4;
lmd5 = b*k5;
lmd6 = k6;
rate = [lmd1 lmd2 lmd3 lmd4 lmd5 lmd6];
lmd = sum(rate);
p= cumsum(rate)/lmd;
U = rand(1,2);
per isakson
per isakson 2014년 11월 26일
Here you assign an array of double to a variable named, ts. Confusing!

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

카테고리

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