Conditional Calculations or Loop
显示 更早的评论
I've got a question about how Matlab works with conditional formulas. I have a dataset imported that contains tickers, dates, and returns (each as separate arrays). What I'd like to calculate eventually are large rolling period medians applying various filters to my datasets. To get started, I'm wondering if someone can point me in the right direction.
What I'd like to do is calculate the product of my (MyReturns) array for each ticker in my tickers array(MyTickers) and a certain time period (MyDates). Once I have all the product’s calculated, I’d like to calculate the median of that dataset and write that value to a separate array for future use and move on to another time period. My Data looks like this (see below)-
Say I want to calculate the Product of MyReturns for MyDates = 1/1 and 1/2. Then find the median of the returns and store that value. How would I go about writing a formula or a loop to do that calculation within Matlab?
Thanks a lot! Brian
MyTickers MyDates MyReturns
GOOG 1/1/2011 1.01
GOOG 1/2/2011 1.02
GOOG 1/3/2011 0.99
GOOG 1/4/2011 0.98
GOOG 1/5/2011 1
AAPL 1/1/2011 1.03
AAPL 1/2/2011 1.01
AAPL 1/3/2011 1.02
AAPL 1/4/2011 0.99
AAPL 1/5/2011 0.98
IBM 1/1/2011 1
IBM 1/2/2011 1.01
IBM 1/3/2011 1.01
IBM 1/4/2011 0.99
IBM 1/5/2011 0.99
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!