Thread Subject:
can a string be asigned to a single element of matrix

Subject: can a string be asigned to a single element of matrix

From: rohit

Date: 11 Jun, 2012 06:08:07

Message: 1 of 3

can a string be asigned to a single element of matrix?
like i have a string, a='i am there'
then here 'a' is a vector of size 10.
What i want is to assign this whole string into an element of a matrix.
like say b(2,1) = a;
is it possible?

Subject: can a string be asigned to a single element of matrix

From: Nasser M. Abbasi

Date: 11 Jun, 2012 06:40:45

Message: 2 of 3

On 6/11/2012 1:08 AM, rohit wrote:
> can a string be asigned to a single element of matrix?
> like i have a string, a='i am there'
> then here 'a' is a vector of size 10.
> What i want is to assign this whole string into an element of a matrix.
> like say b(2,1) = a;
> is it possible?

a matrix in matlab is for numbers.
if you want to make a 'matrix' that contains not just
numbers but other stuff like string, try a cell array.
You can make cell matrix or cell vector.

EDU>> A=cell(10,1);
EDU>> a='micky mouse'
EDU>> A{2}=a
A =
     []
     'micky mouse'
     []
     []
     []
     []
     []
     []
     []
     []

by the way, you said above

>here 'a' is a vector of size 10

then you wrote

>b(2,1) =

why? a vector is 1D not 2D.

--Nasser

--Nasser

Subject: can a string be asigned to a single element of matrix

From: rohit

Date: 11 Jun, 2012 06:56:06

Message: 3 of 3

Thanks Nasser, I did not know abt cell matrix.. the problem is solved!!

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us