From: Tomaz on
Hi!
I am trying to store some words into a vector/ matrix. I noticed that they are treated as chars in Matlab. So, my questions is: is it possible to get a particular word (string) instead of char?

To be more clear, here is example:
columnNames = ['TOTSPACE','LIVSPACE','KITSPACE','DISTKM','ROOMS','BRICK'];

I would like to get TOTSPACE when I type in columnNames(1). Currently I am getting 'T'. Is there any trick/ method to do this?
From: Tomaz on
"Tomaz " <tomaz.bartolj(a)gmail.com> wrote in message <hq94rg$l1q$1(a)fred.mathworks.com>...
> Hi!
> I am trying to store some words into a vector/ matrix. I noticed that they are treated as chars in Matlab. So, my questions is: is it possible to get a particular word (string) instead of char?
>
> To be more clear, here is example:
> columnNames = ['TOTSPACE','LIVSPACE','KITSPACE','DISTKM','ROOMS','BRICK'];
>
> I would like to get TOTSPACE when I type in columnNames(1). Currently I am getting 'T'. Is there any trick/ method to do this?

OK, I can answer my own question (just in case somebody else will be looking for solution as well). You put strings into cells and than read specific cell value:

columnNames = {'TOTSPACE','LIVSPACE','KITSPACE','DISTKM','ROOMS','BRICK'};
someText = columnNames{1,i};
From: Tomaz on
"Tomaz " <tomaz.bartolj(a)gmail.com> wrote in message <hq94rg$l1q$1(a)fred.mathworks.com>...
> Hi!
> I am trying to store some words into a vector/ matrix. I noticed that they are treated as chars in Matlab. So, my questions is: is it possible to get a particular word (string) instead of char?
>
> To be more clear, here is example:
> columnNames = ['TOTSPACE','LIVSPACE','KITSPACE','DISTKM','ROOMS','BRICK'];
>
> I would like to get TOTSPACE when I type in columnNames(1). Currently I am getting 'T'. Is there any trick/ method to do this.

OK, I can answer my own question (in case somebody else will be looking for solution too). You store strings into cell array and than look at value of specific cell.

columnNames = {'TOTSPACE','LIVSPACE','KITSPACE','DISTKM','ROOMS','BRICK'};
someText = columnNames{1,i};
From: James Tursa on
"Tomaz " <tomaz.bartolj(a)gmail.com> wrote in message <hq94rg$l1q$1(a)fred.mathworks.com>...
> Hi!
> I am trying to store some words into a vector/ matrix. I noticed that they are treated as chars in Matlab. So, my questions is: is it possible to get a particular word (string) instead of char?
>
> To be more clear, here is example:
> columnNames = ['TOTSPACE','LIVSPACE','KITSPACE','DISTKM','ROOMS','BRICK'];
>
> I would like to get TOTSPACE when I type in columnNames(1). Currently I am getting 'T'. Is there any trick/ method to do this?

You could use cell arrays for this. e.g.,

columnNames = {'TOTSPACE','LIVSPACE','KITSPACE','DISTKM','ROOMS','BRICK'};

Then to get the contents of each cell, use the curly braces instead of the brackets. e.g.,

columnNames{1}

James Tursa