cell2mat returns an error

12 vues (au cours des 30 derniers jours)
Marc Jakobi
Marc Jakobi le 18 Oct 2013
Hi.
I have a large 11000x1 cell array with string values that seems to look something like this in the variables window:
A = {'600'; '400'; '200'; '800'; '600'; '700'}
When I use
cell2mat(A)
I get an error message that says:
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 84)
m{n} = cat(1,c{:,n});
I know the cell array can't be the same as Array 'A' of this example, because I tried it with Array 'A' in the workspace and it worked. I can't find any difference in the variables windows, though.
Here are the propertys
>> whos curr_ch1
Name Size Bytes Class Attributes
curr_ch1 113283x1 13474862 cell
Any idea what could be the problem?

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 18 Oct 2013
A= {'600'; '400'; '200'; '800'; '600'; '700'}
cellfun(@str2double,A)
  1 commentaire
Marc Jakobi
Marc Jakobi le 18 Oct 2013
Thanks. That did it!

Connectez-vous pour commenter.

Plus de réponses (1)

Andrei Bobrov
Andrei Bobrov le 18 Oct 2013
Just:
str2double(A)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by