How can I divide arrays into two as higher and lower?

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

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.
my arrays like this. As a result, I want to create two arrays. The name of a directory is "noise" and the name of a directory is "signal". Both of these strings will have 24 rows. For example, the value in the first row of the T array is 0.0232. It will compare this value with the 832 value in row 1 of the yy array. will write the numbers in this row greater than 0.0232 in line 1 of the "signal" array. will write the smaller numbers on the line of the "noise" array. then these operations will be repeated for 24 rows. for example, row 2 will compare with the value 0.0123.
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);
This is a good example, thank you very much. but the result I want for the signal array is exactly like this:
I would appreciate it if you could help me on how to do this.
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.
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.
@dpbThank you very much for your warnings. i'm a little newbie, i will take into account what you say. I renewed my question.
@DGM thank you for code. it is running correctly.

Sign in to comment.

Answers (0)

Asked:

on 25 Apr 2021

Commented:

DGM
on 25 Apr 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!