Generate a matrix of random numbers, with a random number of  rows (below a maximum that we set),  each made of a random number of elements (below a maximum that we set)

AbsoluteTiming[RandomReal[{0,1},10^8];]

AbsoluteTiming[Table[Random[],{10^8}];]

Calling the Random[] functions many times is usually less efficient than calling it once and requesting all the random numbers at once.

Prototype of GenerateData

Table[Random[],{9}]

Table[Random[],{RandomInteger[{1,12}]}]
Length[%]

Table[
Table[Random[],{RandomInteger[{1,12}]}]
,{7}
]
Length[%]

Table[
Table[Random[],{RandomInteger[{1,12}]}]
,{RandomInteger[{1,12}]}
]
Length[%]

maxCols=2
maxRows=1
Table[
Table[RandomReal[{0,2}],{RandomInteger[{1,maxRows}]}]
,{RandomInteger[{1,maxCols}]}
]

Table[{i,j},{j,1,3},{i,1,4}]
MatrixForm[%]

Table[{{i},{j}},{i,1,4},{j,1,3}]
MatrixForm[%]

Table["("<>ToString[i]<>","<>ToString[j]<>")",{i,1,4},{j,1,3}]
%//MatrixForm

Table[Subscript[M,i,j],{i,1,4},{j,1,3}]
%//MatrixForm

GenerateData

GenerateData::usage="First argument is number of collumns, last argument is number of rows."

??GenerateData

GenerateData[maxCols_,maxRows_]:=
Table[
RandomReal[],{RandomInteger[{1,maxRows}]},{RandomInteger[{1,maxCols}]}
]

GenerateData[12,2]

Import/Read Data

RndMatrix=GenerateData[12,15]

TableForm[RndMatrix,TableHeadings->{Table["Giorno n."<>ToString[i],{i,1,14}], {"Distanza"}}]

The computation function

(* This is the function to be used for "the computation" *)
CloseBy[a_,b_,dist_]:=If[2((Abs[a-b])/(a+b))<dist,True,False,False]

Application of the function to the data

Example of hard-wired parameter and how to do better

(* Apply the calculation to one row *)
CheckClosebyOnRow[ReferenceValue_,thisRow_]:=Module[{$i},
For[$i = 1, $i≤Length[thisRow],$i++,
CloseBy[thisRow[[$i]],ReferenceValue ,0.1]
]
]

The fixed 0.1 is bad practice, it should be avoided. If you put a number like that hidden in a function you will never remember it was there in the first place. It is much better to have it as parameter of the function.

If it needs to be changed frequently, make it a true parameter

(* Apply the calculation to one row, keep the distance as a parameter *)
Clear[CheckClosebyOnRow]
CheckClosebyOnRow[ReferenceValue_,thisRow_, distance_]:=Module[{$i},
For[$i = 1, $i≤Length[thisRow],$i++,
CloseBy[thisRow[[$i]],ReferenceValue ,distance]
]
]

Plot

If it needs to be changed only rarely, make it an optional parameter, with a sensible default

(* Apply the calculation to one row. Distance is an optional parameter *)
Clear[CheckClosebyOnRow]
Options[CheckClosebyOnRow]={Distance->0.1}
CheckClosebyOnRow[ReferenceValue_,thisRow_, opt:OptionsPattern[]]:=Module[{$i},
For[$i = 1, $i≤Length[thisRow],$i++,
CloseBy[thisRow[[$i]],ReferenceValue ,OptionValue[Distance]]
]
]

CheckClosebyOnRow[0.1,RndMatrix[[1]],Distance->0.2]

(* Apply the calculation to one row. Distance is an optional parameter *)
Clear[CheckClosebyOnRow]
Options[CheckClosebyOnRow]={Distance->0.1}
CheckClosebyOnRow[ReferenceValue_,thisRow_, opt:OptionsPattern[]]:=Module[{$i,result={}},
For[$i = 1, $i≤Length[thisRow],$i++,
result=AppendTo[result,CloseBy[thisRow[[$i]],ReferenceValue ,OptionValue[Distance]]]
];(* End for *)
result
](* End module *)

Apply to each row

I can now apply the calculation to my matrix by using on each row the function that computes what I want on a given row.

CheckClosebyOnMatrix[ReferenceValue_]:=
(* Use the check on each row *)
Module[{$i},
For[$i = 1, $i≤Length[RndMatrix],$i++,
CheckClosebyOnRow[ReferenceValue,RndMatrix[[$i]] ]
]
]

CheckClosebyOnMatrix[0.1]

Please note that the above functions do the calculations, but do not output anything.

Let us redefine them so that they return something.

CheckClosebyOnMatrix[ReferenceValue_]:=
(* Use the check on each row *)
Module[{$i,result={}},
For[$i = 1, $i≤Length[RndMatrix],$i++,
result=AppendTo[result,CheckClosebyOnRow[ReferenceValue,RndMatrix[[$i]] ] ];
]; (* end FOR *)
result
] (* end Module *)

The check on the row is redefined similarly.

CheckClosebyOnMatrix[0.1]

Find the elements that are closer to  values already in the array.

Let us assume that the order of the layer has the meaning of time of arrival of the data. For instance each row may be a day of data-taking, with the first row being the batch of data we recorded the first day of data taking, the second row data from day-2 and so on.

We imagine the values recorded is a spatial coordinate of some event, say distance from you house in Km.

All in all the data is
     time (rows) vs. distance (the value) of some events (for instance car accidents) whose number is different every day.

Let us start to check from the last recorded data and proceed back in time

MatrixPlot[RndMatrix,PlotLegends->Automatic]

CheckClosebyOnMatrix[RndMatrix[[-1,-1]]]
Map[If[#,1,0,0]&,%,{2}]
MatrixPlot[%]

Now I can inspect which values are close to the one I have selected

Position[CheckClosebyOnMatrix[0.1],True]

First row, element 8;
Second row, element 2;
Third row element 6;