Simple logical statement
5 views (last 30 days)
Show older comments
Hi I have a question about logical statements.
I have a data set which includes some positive and some negative observations. I need to transform this data set is such a way that all observations that are positive become zero and those that are negative stay the same. What I have is the following:
SP_prices = xlsread('SP500_plusyear.xls', 'b2:b2780');
SP_returns = log(SP_prices(2:end)) - log(SP_prices(1:end-1));
SP_returns_extra = SP_returns(2527:end);
if (SP_returns_extra > 0)
{then SP_returns_extra = 0}
But this doesn't work, so I was wondering how I can change what I have to make it work. Thanks.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!