Converting cell in double
Mostra commenti meno recenti
Hey Guys,
i have a 8942x1 cell and want to convert it into a 8942x1 double ? The final product should be look likes this:
[] 0
1 1
[] => 0
[] 0
[] 0
... ...
Thank you very much for your help!
Attached my file:
Risposta accettata
Più risposte (1)
Simpler and more efficient:
S = load('ids.mat');
ids = S.ids
Method one: robust indexing:
X = cellfun(@isscalar,ids);
V = zeros(size(ids));
V(X) = [ids{X}]
Method two: VERTCAT():
ids(~cellfun(@isscalar,ids)) = {0};
V = vertcat(ids{:})
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!