how insert char in Cell Array

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how insert char in Cell Array

LucaLuca
hi,

i want to convert cell in matrix

i do an example:

c = {"1", "2", "3"; "x", "y", "z"; "4", "5", "6"};

cell2mat(c)

ans =

123
xyz
456

But it's wrong..

i want get matrix with :
 1 2 3
 x y z
 4 5 6

I was wrong to enter data in the cell?





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: how insert char in Cell Array

Mike Miller-4
On Sat, Aug 25, 2018 at 20:57:30 -0500, LucaLuca wrote:

> hi,
>
> i want to convert cell in matrix
>
> i do an example:
>
> c = {"1", "2", "3"; "x", "y", "z"; "4", "5", "6"};
>
> cell2mat(c)
>
> ans =
>
> 123
> xyz
> 456
>
> But it's wrong..
>
> i want get matrix with :
>  1 2 3
>  x y z
>  4 5 6
Do you really want a 3-by-5 matrix?

Do you want A(2,2) to be a space and A(2,5) to be 'z'?

If so, then you might want to use the strjoin function to insert spaces.

--
mike



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how insert char in Cell Array

LucaLuca
This post was updated on .
Hi..

why do you say "Do you really want a 3-by-5 matrix? "

i don't see matrix 3 by 5 (3 X 5)

i see matrix 3 by 3(3X 3)





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: how insert char in Cell Array

Mike Miller-4
In reply to this post by Mike Miller-4
On Sun, Aug 26, 2018 at 13:32:33 -0500, LucaLuca wrote:

> hi mike,
>
> i want to insert some scalar,string in cell array
>
> after I need to convert it in Matrix
>
>
> Example:
>
>
> rows 1: 4,"bla bla",6,7,"tic tic"
>
> rows 2: 6,"jka ", 8, 3, "bhi "
>
> it's an example..
>
> I need to put rows1 and rows2 in a cell array
>
> how can I insert them in the cell array?
>
>
> I do not know what is the best method to insert it
> (after I have to use cell2mat)
Sorry, I have no idea what you are asking for help with.

It looks like you want to have a cell array that looks like

    A = {
          4, "bla bla", 6, 7, "tic tic";
          6, "jka ", 8, 3, "bhi ";
        };

But it's not at all clear what your starting point is, or how this
relates to your previous question about using cell2mat.

Cheers,

--
mike



signature.asc (849 bytes) Download Attachment