Combining Logical Indexes
6 次查看(过去 30 天)
显示 更早的评论
I have two logical Indexes that I need to reference with my large Matrix of data before performingons. One Index (MyDates) is 1x693 and the other (MyTickers) is 589x1. I need to combine the two Indexes into one large 589x693 logical index. How do I go about oing that?
Thanks, Brian
0 个评论
采纳的回答
Fangjun Jiang
2011-11-4
What is the operation, and, or, plus, minus?
bsxfun(@and,MyTickers,MyDates)
3 个评论
Sean de Wolski
2011-11-4
Fangjun is correct! times would work, but it's slightly slower since ML has to do a multiplication instead of a logical operation.
更多回答(1 个)
Brian
2011-11-4
2 个评论
Walter Roberson
2011-11-4
What shape were you expecting? When you extract arbitrary elements out of a matrix, there is no way for MATLAB to leave "hole" that preserve any original existing shape.
Fangjun Jiang
2011-11-4
That is expected. If you want to keep the shape of the original matrix, you need fill it with something depending on your need. For example,
a=magic(3);
b=logical([1 1 0;0 1 0;0 1 0]);
a(~b)=nan;
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!