开发者

Using matlab and Time Series object (fints), how can I make an array of them?

开发者 https://www.devze.com 2022-12-31 03:40 出处:网络
I am getting stock prices from yahoo, and want to have each stock have its own time series data str开发者_开发技巧ucture, but also don\'t want to have hundreds of variables, so naturally I would want

I am getting stock prices from yahoo, and want to have each stock have its own time series data str开发者_开发技巧ucture, but also don't want to have hundreds of variables, so naturally I would want to have an array, but when I do something like array = [stock1 stock2]; it actually merges the series together. How can I make a real array? Thanks, CP


[x x] notation in matlab is not an array, it is a vector. It is assumed that what you're putting together belongs together. What you probably want is a cell array which is indexed with a curly brace, ie myArray{1} = stock1; myArray{2} = stock2;. Reference here.


Ah, since you have row vectors, [stock1 stock2] is a concatenation. If you want to create a 2-by-x array instead, do something like this [stock1; stock2], which will place one array above the other.


Joining vectors using [x y] has different results depending on whether your vectors are rows or columns. If rows, then joining them with [x y] makes a longer row vector, but if columns, you'll get a Nx2 matrix. You should probably convert them to column vectors using the TRANSPOSE operator thus: [x' y']. Although you should check if transpose means the same thing with Time Series objects as at does with regular vectors.

0

精彩评论

暂无评论...
验证码 换一张
取 消