how to find and replace corresponding matri

2 Ansichten (letzte 30 Tage)
Triveni
Triveni am 19 Mai 2016
Bearbeitet: VBBV am 26 Jul. 2023
a1{:}
ans =
73.3333 50.0000
66.6667 50.0000
ans =
Empty matrix: 0-by-2
ans =
Empty matrix: 0-by-2
ans =
Empty matrix: 0-by-2
ans =
Empty matrix: 0-by-2
ans =
Empty matrix: 0-by-2
i need to find index for non zero cell array, and convert in into mat.

Antworten (3)

Azzi Abdelmalek
Azzi Abdelmalek am 19 Mai 2016
Bearbeitet: Azzi Abdelmalek am 19 Mai 2016
idx=celfun(@isempty,a1)
a1(idx)=[]
out=cell2mat(a1)

Andrei Bobrov
Andrei Bobrov am 19 Mai 2016
out = cat(1,a1{:})

Guillaume
Guillaume am 19 Mai 2016
Bearbeitet: VBBV am 26 Jul. 2023
idx = find(~cellfun(@isempty, a1)); %index of non empty cell
assert(numel(idx) == 1, 'There are more or less than 1 empty cell')
out = a1{idx}; %get content of cell, which is a matrix in your case

Kategorien

Mehr zu Matrices and Arrays 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!

Translated by