Converting data from two cell arrays in one vector

8 visualizzazioni (ultimi 30 giorni)
Lotte
Lotte il 12 Dic 2020
Commentato: Rik il 12 Dic 2020
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!

Risposte (1)

Rik
Rik il 12 Dic 2020
Modificato: Rik il 12 Dic 2020
Je zou je klasgenoot kunnen vragen, ik heb gisteren bijna de zelfde vraag beantwoord: link.
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 Commenti
Gitte
Gitte il 12 Dic 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
Rik il 12 Dic 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.

Accedi per commentare.

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by