From: Nilesh on
I have been working on string . i got into a small problem.the problem is here as under
here 's' is a structure
------
str = 'name'

name

s(1).(str) %works

-------

str = fields1(1) %fields1 = fieldnames(s)

'name'

s(1).(str) % does not work .

here when i assign directly the str with required string , it contains no quotes.But if assign the str using the fields1 array the output is with quote but i dont want the quotes as its causing me problem of not able to access the element od the structure.Is ther anyway to solve this so that i can access the structure elements using the fieldnames array.

Thanks,
NILESH
From: Andy on
"Nilesh " <nileshjavar(a)gmail.com> wrote in message <i249ij$df3$1(a)fred.mathworks.com>...
> I have been working on string . i got into a small problem.the problem is here as under
> here 's' is a structure
> ------
> str = 'name'
>
> name
>
> s(1).(str) %works
>
> -------
>
> str = fields1(1) %fields1 = fieldnames(s)
>
> 'name'
>
> s(1).(str) % does not work .
>
> here when i assign directly the str with required string , it contains no quotes.But if assign the str using the fields1 array the output is with quote but i dont want the quotes as its causing me problem of not able to access the element od the structure.Is ther anyway to solve this so that i can access the structure elements using the fieldnames array.
>
> Thanks,
> NILESH

A hint: what type does the function fieldnames return?
From: Steven_Lord on


"Nilesh " <nileshjavar(a)gmail.com> wrote in message
news:i249ij$df3$1(a)fred.mathworks.com...
> I have been working on string . i got into a small problem.the problem is
> here as under
> here 's' is a structure
> ------
> str = 'name'
>
> name
>
> s(1).(str) %works
>
> -------
>
> str = fields1(1) %fields1 = fieldnames(s)
>
> 'name'

Look at the data type of fields1 (and str) using WHOS. They are NOT 'char
arrays' -- they are 'cell arrays', and to extract the _contents_ of a cell
from a cell array rather than the cell itself, use curly brace indexing.

fields1{1}

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: someone on
"Nilesh " <nileshjavar(a)gmail.com> wrote in message <i249ij$df3$1(a)fred.mathworks.com>...
> I have been working on string . i got into a small problem.the problem is here as under
> here 's' is a structure
> ------
> str = 'name'
>
> name
>
> s(1).(str) %works
>
> -------
>
> str = fields1(1) %fields1 = fieldnames(s)
>
> 'name'
>
> s(1).(str) % does not work .

% Try:
s(1).(str{1})

>
> here when i assign directly the str with required string , it contains no quotes.But if assign the str using the fields1 array the output is with quote but i dont want the quotes as its causing me problem of not able to access the element od the structure.Is ther anyway to solve this so that i can access the structure elements using the fieldnames array.
>
> Thanks,
> NILESH
From: Nilesh on
"Steven_Lord" <slord(a)mathworks.com> wrote in message <i24ab0$3iv$1(a)fred.mathworks.com>...
>
>
> "Nilesh " <nileshjavar(a)gmail.com> wrote in message
> news:i249ij$df3$1(a)fred.mathworks.com...
> > I have been working on string . i got into a small problem.the problem is
> > here as under
> > here 's' is a structure
> > ------
> > str = 'name'
> >
> > name
> >
> > s(1).(str) %works
> >
> > -------
> >
> > str = fields1(1) %fields1 = fieldnames(s)
> >
> > 'name'
>
> Look at the data type of fields1 (and str) using WHOS. They are NOT 'char
> arrays' -- they are 'cell arrays', and to extract the _contents_ of a cell
> from a cell array rather than the cell itself, use curly brace indexing.
>
> fields1{1}
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


Thanks alot ...i could not look so deep .It solved the problem.