Is it possible to assign ranges to a matrix. If you consider the below zeros matrix as a 'grid' for plotting:
R = zeros(5,8);
R =
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
So can you treat this matrix as a grid so each x-axis zero can considered as a range? for example R(5,1)
is a range 0-0.1 seconds
. R(5,2)
is a range 0.1-0.2 seconds
etc.
Can the range idea also be applied to the columns?
The purpose for this is so I can read cell array data I have already organised into ranges into the zeros matrix to produce a 2d histogram.
Assume you have the times
tt
and the datavaluesval
, whereval(i)
contains the datavalue for timett(i)
. In your example you would haveNow you need vectors that represent the time and data ranges that you want (increasing), for example
Now you create a matrix of the right size
You can fill the matrix up easily just by looping over all times you have
Note that the first column corresponds to the time range between
-Inf
totrange(1)
and the last column to the range betweentrange(end-1)
andtrange(end)==Inf
. Simliary for the first and last row.I'm not sure if I understand your question.
If you ask, whether it is possible to assign a vector, e.g.
a = [1;2;3]
, to be a column in some matrixR = zeros(3, 5)
, then this can be achieved by