Converting cell in double
Show older comments
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:
Accepted Answer
More Answers (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{:})
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!