Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to compare two matrices of different dimentions and get the result in new column
2 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
i wanne compare data in two column and get the result in a new column if my condition is true.
A = [2000;1950 ; 1980;2500 ; 2000 ; 5000 ; 2300 ;2000'];
B = [2;2;1;3;1;5;3;3 ; 2;3];
wanne go through all value in B and write in new column when they meet/ equal to 2000.
many thanks
/SA
2 个评论
Alex Mcaulley
2019-6-13
The question is not clear to me. What is the expected result in your example?
回答(3 个)
Fabio Freschi
2019-6-17
Try this
% find logical indices in A with 2000
idxLog = A == 2000;
% create the new vector with B values in idxLog and zeros in ~idxLog
Bnew = zeros(size(B));
Bnew(idxLog) = B(idxLog);
However it is still puzzling me why A and B have different dimensions
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!