Prev: Formatting and displaying histogram
Next: can someone help me with the constrained optimization ?
From: Tomaz on 16 Apr 2010 03:50 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 16 Apr 2010 04:05 "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 16 Apr 2010 04:08 "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 16 Apr 2010 04:10 "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
|
Pages: 1 Prev: Formatting and displaying histogram Next: can someone help me with the constrained optimization ? |