From: zemax on
I have <39X1> cell that I am trying to convert to matrix. When I use cell2mat I get the following error msg:

Chi_cell =

'4.53725e-006'
'4.87675e-006'
'5.62039e-006'
'6.41923e-006'
'4.37755e-006'
'3.65092e-006'
'7.15641e-006'
'3.99299e-006'
'3.82947e-006'
'6.05986e-006'
'5.30846e-006'

>> chimat = cell2mat(Chi_cell);
??? Error using ==> cat
CAT arguments dimensions are not consistent.

Error in ==> cell2mat at 89
m{n} = cat(1,c{:,n});

I would appreciate if someone as point my mistake or let me know how could I convert this into matrix.

Thanks.
From: Matt J on
zemax <zemax2000(a)yahoo.com> wrote in message <34890761.130708.1265640785406.JavaMail.root(a)gallium.mathforum.org>...
> I have <39X1> cell that I am trying to convert to matrix. When I use cell2mat I get the following error msg:
>
> Chi_cell =
>
> '4.53725e-006'
> '4.87675e-006'
> '5.62039e-006'
> '6.41923e-006'
> '4.37755e-006'
> '3.65092e-006'
> '7.15641e-006'
> '3.99299e-006'
> '3.82947e-006'
> '6.05986e-006'
> '5.30846e-006'
>
> >> chimat = cell2mat(Chi_cell);


strvcat(Chi_cell{:});
From: Jos (10584) on
zemax <zemax2000(a)yahoo.com> wrote in message <34890761.130708.1265640785406.JavaMail.root(a)gallium.mathforum.org>...
> I have <39X1> cell that I am trying to convert to matrix. When I use cell2mat I get the following error msg:
>
> Chi_cell =
>
> '4.53725e-006'
> '4.87675e-006'
> '5.62039e-006'
> '6.41923e-006'
> '4.37755e-006'
> '3.65092e-006'
> '7.15641e-006'
> '3.99299e-006'
> '3.82947e-006'
> '6.05986e-006'
> '5.30846e-006'
>
> >> chimat = cell2mat(Chi_cell);
> ??? Error using ==> cat
> CAT arguments dimensions are not consistent.
>
> Error in ==> cell2mat at 89
> m{n} = cat(1,c{:,n});
>
> I would appreciate if someone as point my mistake or let me know how could I convert this into matrix.
>
> Thanks.

Apparently Chi_cell contains character arrays instead of numeric values, so you need another type of conversion than CELL2MAT

help str2double

hth
Jos
From: zemax on
Thanks. But if my input cell has size of <39X2> and I use strv2cat and then use str2num then it messes up the actual format by putting col1 and col2 on top of each other and making them one col. Any solution for that other than manually arranging them?
From: zemax on
Thanks. It fixed the problem.