Thread Subject: how to write struct field into txt file?

Subject: how to write struct field into txt file?

From: Tiger Smith

Date: 6 Nov, 2009 22:27:01

Message: 1 of 3

Hi there,
  I have a struct a which has fields name, time,bytes,isdir.
  And a.name are cells like
  'data-001-05-26-09.dat
   data-002-00589.dat
   data-3-005-9.dat...........'
   
   
I want to write a.name to a .txt file.

Does anybody has some suggestion?
Thank you.

Subject: how to write struct field into txt file?

From: Cesare

Date: 17 Jan, 2010 09:52:03

Message: 2 of 3

Hi!
the basic way is to use fopen, fprintf and fclose. You can even write m-files this way.
I got to your post cause I was looking for a function that did it automatically for any structure, but don't know whether it exists.
Best,
Cesare


"Tiger Smith" <loscleaa@gmail.com> wrote in message <hd27rl$rc4$1@fred.mathworks.com>...
> Hi there,
> I have a struct a which has fields name, time,bytes,isdir.
> And a.name are cells like
> 'data-001-05-26-09.dat
> data-002-00589.dat
> data-3-005-9.dat...........'
>
>
> I want to write a.name to a .txt file.
>
> Does anybody has some suggestion?
> Thank you.

Subject: how to write struct field into txt file?

From: Oleg Komarov

Date: 17 Jan, 2010 14:16:03

Message: 3 of 3

"Tiger Smith"
> Hi there,
> I have a struct a which has fields name, time,bytes,isdir.
> And a.name are cells like
> 'data-001-05-26-09.dat
> data-002-00589.dat
> data-3-005-9.dat...........'
>
>
> I want to write a.name to a .txt file.
>
> Does anybody has some suggestion?
> Thank you.
Some basic struct manipulation:
myStruct(1).name = 'John';
myStruct(2).name = 'Matt';
myStruct(3).name = 'Alexander';

Names = strvcat(myStruct.name)
Names =
John
Matt
Alexander

The same goes for the other fields.
theTimes = [myStruct.time];

Cesare indicated you some fcn for writing your data to .txt.

Oleg

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
struct write tx... Tiger Smith 6 Nov, 2009 17:29:05
rssFeed for this Thread

Contact us at files@mathworks.com