Matlab: trasform cell arrays into a matrix

1 Ansicht (letzte 30 Tage)
elisa ewin
elisa ewin am 7 Sep. 2016
Bearbeitet: Andrei Bobrov am 7 Sep. 2016
Hi,
I want to trasform U (attacched) in a matrix Z 5 x 12
Z=[0 0 0 0 0 0 0 0 0 0 1933724 260957; 341255 0 0 0 0 0 0 0 0 0 16907 0; 23261 0 0 0 0 0 0 153505 0 420315 0 15372; 0 0 0 0 0 0 0 0 0 5535878 0 0; 0 0 0 0 0 0 0 0 0 16516 0 316637]
Can you help me? Thanks

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 7 Sep. 2016
Bearbeitet: Andrei Bobrov am 7 Sep. 2016
zz = cat(1,U{:});
zz(cellfun(@isempty,zz)) = {0};
Z = cellfun(@(x)x(1),zz);

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by