Azzera filtri
Azzera filtri

put number in cell

3 visualizzazioni (ultimi 30 giorni)
NA
NA il 24 Mag 2019
Modificato: madhan ravi il 24 Mag 2019
A={[21],[],[32],[4],[60],[]};
length_A = cellfun(@(m) length(m),A,'uni',0);
B= cell(1, size(A,2));
B(cell2mat(length_A)) = 0.2;
'A' has empty elements, I want to put empty elements as 0 in B. For other element it should be 0.2
I want to have this result
B={[0.2],[0],[0.2],[0.2],[0.2],[0]};

Risposta accettata

madhan ravi
madhan ravi il 24 Mag 2019
Modificato: madhan ravi il 24 Mag 2019
B = num2cell(~cellfun('isempty',A) * .2)

Più risposte (1)

Catalytic
Catalytic il 24 Mag 2019
Modificato: Catalytic il 24 Mag 2019
B=~cellfun('isempty',A)*0.2

Categorie

Scopri di più su Data Types 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