Converting data from two cell arrays in one vector
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to convert data from two cell arrays into a new cell array with in each cell a vector of the combined cell arrays values.
So I want to have a new cell array, with in each cell the corresponding values Bmin_HR and Bmax_HR, like [min max]. Thus, we want a 10x5 cell array, with in each cell the vector of the minimum and maximum (values of min and max can be find in Bmin_HR and BmaxHR).
Thanks in advance!
0 Kommentare
Antworten (1)
Rik
am 12 Dez. 2020
Bearbeitet: Rik
am 12 Dez. 2020
Continuing in English: that should be easy to adapt to find the minimum value as well.
You can't convert the cell array to a double because not every cell has a value. If you choose a default value (like 0 or NaN) you can:
Bmax_HR(cellfun('isempty',Bmax_HR))={NaN};
cell2mat(Bmax_HR)
4 Kommentare
Gitte
am 12 Dez. 2020
It worked! But we still don't find how we can make a matrix with a vector in every cell. The vector must have the value of (1,1) in Bmin_HR and the value of (1,1) in Bmax_HR. So that we have a matrix with in every cell [Bmin Bmax].
Rik
am 12 Dez. 2020
You can even combine that into 1 call:
minmax=cellfun(@(x) [min(x) max(x)],data,'UniformOutput',false);
Note that you will not be able to convert that to a double of the same size, as you can only have 1 value in each element of a double. Cell arrays allow you to have a single variable in each element.
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!