How can I divide arrays into two as higher and lower?
Show older comments
I have two TV arrays. T array consists of 10 rows and 1 column. The Y array consists of 10 rows and 5 columns. I want it to compare the 1st row of the T array with all the links of the 1st row of Y array. Let the values of Y sequence assign to line 1 of another array with greater than T, and write to the smaller one on line 1 of another array. But I want these done for 24 lines as well. For this, I tried a code like this but I did not get the right result. I would be very happy if you could help.
T=[50;20;10;40;90;100;50;10;70;80;50]
Y=[83,69,13,50,77 ; 41,15,33,5,67; ...]
result;
signal=[83,69,50,77 ; 41,33,67 ; ...]
noise=[13 ; 15,5 ; ...]
for i=1:24
index = find(Y(i,:)> T(i,1), 1, 'first');
noise= Y(1:index);
signal= Y(index+1 : end);
end
9 Comments
dpb
on 25 Apr 2021
I can't make heads nor tails of the desired result, sorry.
GIve us a small sample of a dataset and show us what the expected result is and the logic by how you arrived at that being the correct result.
Four or five rows and 8-10 columns would be plenty with which to illustrate concept.
studentmatlaber
on 25 Apr 2021
DGM
on 25 Apr 2021
Consider the simplified example:
A = ones(10,1)*50; % threshold values
B = randi(89,10,10)+10; % pretend data
mask = bsxfun(@ge,B,A);
signal = B(mask);
noise = B(~mask);
You mention cases for 'greater than' and 'less than', but not necessarily 'equal to'. If you want equality cases to be categorized as noise, just do
mask = bsxfun(@gt,B,A);
studentmatlaber
on 25 Apr 2021
Edited: studentmatlaber
on 25 Apr 2021
DGM
on 25 Apr 2021
You can't really make a non-rectangular numeric array like that. You could store the result rows in a cell array or something.
A = ones(10,1)*50; % threshold values
B = randi(89,10,10)+10; % data
gte = bsxfun(@ge,B,A);
signal = cell(10,1);
noise = cell(10,1);
for m=1:size(B,1)
thisrow = B(m,:);
signal{m} = thisrow(gte(m,:));
noise{m} = thisrow(~gte(m,:));
end
There's probably a better datatype, though.
dpb
on 25 Apr 2021
Attach your sample data as text, not figures...not can do nothink! with pictures but type over again...
And, yet again, give us a SMALL sample dataset we can see the input and result of and 'splain clearly how you get the result you want from that data set.
"Help us help you"
"how to do this."
result={[83,69,73,50,77,85];[91,97,71,84];[96,86,79,69,56,83,63,58]};
is about the only way given what we've been given to work from.
studentmatlaber
on 25 Apr 2021
Edited: studentmatlaber
on 25 Apr 2021
studentmatlaber
on 25 Apr 2021
DGM
on 25 Apr 2021
Glad to hear it
Answers (0)
Categories
Find more on Matrix Indexing 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!
