For Programmers: Free Programming Magazines  


Home > Archive > Matlab > October 2006 > structure array for XTickLabel argument ??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author structure array for XTickLabel argument ??
minnesotti

2006-10-31, 4:06 am


J=E9r=F4me wrote:
> Hi,
>
> try this :
>
> t=3D['19-Dec-1994';'20-Dec-1994';'21-Dec-1994';'22-Dec-1994']
> [d,w] =3D wday(t);
> axes('xlim',[0 3],'xtick',[0 1 2 3],'xticklabel',w)


OK, here is the next problem.

I used "dir" to make a list of files in the directory. "Dir" produced a
structure array (which I called "files"). By using the command
"files(:).name" I was able to extract the list of the files. For each
file, I was able to calculate the temperature. Now I want to plot the
temperature versus the name of the file. Here is where your hint about
setting string values for XTickLabel comes in handy. I put
"[files(:).name]" as an argument for XTickLabel. However, MATLAB gives
error when I am trying to run the m-file. It says something like that
"[files(:).name]" is the different kind of variable than is required
for input. However, when I put, say, "[files(1).name]" as the argument
for XTickLabel, MATLAB plots the graph al'right. This is strange. What
should I do ? It looks like I have to convert the string data from one
type to another. I studied the manual and tried maybe ten ideas, but
still unsuccessfully. Thanks a lot in advance.

Loren Shure

2006-10-31, 8:02 am

In article <1162273034.193660.318760@m73g2000cwd.googlegroups.com>,=20
minnesotti@yahoo.com says...
>=20
> J=E9r=F4me wrote:
>=20
> OK, here is the next problem.
>=20
> I used "dir" to make a list of files in the directory. "Dir" produced a
> structure array (which I called "files"). By using the command
> "files(:).name" I was able to extract the list of the files. For each
> file, I was able to calculate the temperature. Now I want to plot the
> temperature versus the name of the file. Here is where your hint about
> setting string values for XTickLabel comes in handy. I put
> "[files(:).name]" as an argument for XTickLabel. However, MATLAB gives
> error when I am trying to run the m-file. It says something like that
> "[files(:).name]" is the different kind of variable than is required
> for input. However, when I put, say, "[files(1).name]" as the argument
> for XTickLabel, MATLAB plots the graph al'right. This is strange. What
> should I do ? It looks like I have to convert the string data from one
> type to another. I studied the manual and tried maybe ten ideas, but
> still unsuccessfully. Thanks a lot in advance.
>=20
>=20


show the relevant code and error and it'll be easier to help

--Loren
http://blogs.mathworks.com/loren/
Peter Boettcher

2006-10-31, 8:02 am

"minnesotti" <minnesotti@yahoo.com> writes:

> OK, here is the next problem.
>
> I used "dir" to make a list of files in the directory. "Dir" produced a
> structure array (which I called "files"). By using the command
> "files(:).name" I was able to extract the list of the files. For each
> file, I was able to calculate the temperature. Now I want to plot the
> temperature versus the name of the file. Here is where your hint about
> setting string values for XTickLabel comes in handy. I put
> "[files(:).name]" as an argument for XTickLabel. However, MATLAB gives
> error when I am trying to run the m-file. It says something like that
> "[files(:).name]" is the different kind of variable than is required
> for input. However, when I put, say, "[files(1).name]" as the argument
> for XTickLabel, MATLAB plots the graph al'right. This is strange. What
> should I do ? It looks like I have to convert the string data from one
> type to another. I studied the manual and tried maybe ten ideas, but
> still unsuccessfully. Thanks a lot in advance.


Maybe {files(:).name} will work better? Note the curly brackets
instead of the square brackets. The keywords to read up on to learn
more about this are cell arrays, and the difference between 'cell
arrays of strings' and character matrices.


--
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com