Comparison of entries of one data set (just one column) with multiple columns of second data set

Hi everyone,
May someone help me here...
The picture below represent what I want to get. I think this needs 2 to 3 for loops and one if comand only ...
[Let me explain for more clerity:
May someone help me to perform the same calculation for all columns of first data set with the values of seocnd data se. 'a' reprsent the data set consists of 28 columns with diffrent data points; 'b' repsrent the data set of 76 enteries;
Initially, we pick first entry of 'b' suppose called as 'c' then we search in the first columns of 'a' with a condition that column consists of data points values greater than and less then the first vale of 'b'. If this condition not meet, then we look into the second column of 'a', third column and sop one...
When the condition meet... then we split the column into two parts: (1) consits of values greater than the first value of 'b' say 'e'; (2) consists of values less than the first value of b say 'f'. After that, we pick minimum value of 'e' say 'g' and maxium value of 'f' say 'h'. At the last step, I calcualte i=g-c and j=c-h,
later, I get my answer by this relation = i/(i+j)]

Antworten (1)

To check whether all the values are less than or greather than a certain value/array. You can get the logical indices and use nnz. If nnz is equal to the length then the condition is met.
% Let a be any array and val be the value to check
a = rand(10,1) ;
val = 1 ;
n = length(a) ;
idx = a < val ;
if nnz(idx) == n
fprintf("all the elements in a are less than val\n")
end

11 Kommentare

thanks ... this is the second step at first step ... i want to loop the data for diffrent columns of first data set and diffrent rows of second data set ....
If the matrices are of same size.....you can striaght away comapre them.
A = rand(5) ; B = rand(5) ;
idx1 = A>B
idx2 = A<B
No matrix size is diffrent ....
If you have a single value to comapre with matrix.
A = rand(5) ;
val = rand ;
idx - A<val ;
If you have different arrays, you can use:
A = rand(5,1) ; B = rand(3,1) ;
idx = A.'>B
hi ... see this work perfectly for first column of a but how i generalzed this for rest of the columns
What are diemnsions of a and b?
b is a column with 76 enteries and
a has 28 column with diffrent number of enteries ...
at first i need to pick first entry say 'ii' from b and then split all the columns of a into two parts
(1) all enteries greater than i'i' and (2) all enteries less then "ii"
What I mean by dimension is what is
size(a)
size(b)
The number of rows and columns present in the array.
size (a) =64478by 28
size (b)=76 by 1
for i = 1:64478
u = vpslit(b,a(:,i)) ;
end
I think, I did not convey the question ... I try to summarzed the key points in this example ...
Data set 1 has 78 values and data set 2 has 28 column with multiple values ..
everytime , i just have to pick the values from data set 1 ,,,, then look for the imediate higher and lower values
in each colum of data set 2 ...
if our value is inbetween the values of the columns of data set 2 ... then we look for further analysis ...
like ..
first entry of data set 1 is 3 that is not present in first colum of data set 2 .. then we move towards the second column of data set 2 ..
and calculate the diffrence from the imediate higher(9-3)/(9-3)+(3-1) and lower value and so on ...
this is what is exactly, looking for

Diese Frage ist geschlossen.

Tags

Gefragt:

aa
am 12 Sep. 2020

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by