Thread Subject: Problem with fprintf

Subject: Problem with fprintf

From: Nico zanette

Date: 14 Jul, 2009 06:03:02

Message: 1 of 6

Hi
I have a problem with this:

SLICE_NUMBER = 150
fid = fopen ('C:\Users\hp\Desktop\TESI\Modello.Seno\Phantom.1\sliceHp.txt', 'wt');
for J_X_FOR = 1 : DISCRETIZZAZIONE_X
    for K_X_FOR = 1 : DISCRETIZZAZIONE_Z
         SLICE_H(K_X_FOR, J_X_FOR) = MATRICE_3D_PROPRIETA(J_X_FOR,SLICE_NUMBER, K_X_FOR);
        fprintf (fid,'%1.1\n',SLICE_H);
    end
end
fclose(fid);

I'm able to create sliceHp.txt, but i can't write nothing in it. In my mind sliceHp have to be a single column of data.
I want to take SLICE_H(K_X_FOR, J_X_FOR) and put his data on sliceHp.txt, but i obtained only an empty txt file.

Can you help me?

thnks

Subject: Problem with fprintf

From: Bruno Luong

Date: 14 Jul, 2009 07:08:01

Message: 2 of 6


> fprintf (fid,'%1.1\n',SLICE_H);

It miss something important in the format string. 'f', 'g', 'e'?

Bruno

Subject: Problem with fprintf

From: Nico zanette

Date: 14 Jul, 2009 10:03:05

Message: 3 of 6

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h3hash$frb$1@fred.mathworks.com>...
>
> > fprintf (fid,'%1.1\n',SLICE_H);
>
> It miss something important in the format string. 'f', 'g', 'e'?
>
> Bruno

really? i only want to copy the data of slice_H() into sliceHp.txt

Subject: Problem with fprintf

From: Rune Allnor

Date: 14 Jul, 2009 10:09:56

Message: 4 of 6

On 14 Jul, 12:03, "Nico zanette" <zannak...@hotmail.com> wrote:
> "Bruno Luong" <b.lu...@fogale.findmycountry> wrote in message <h3hash$fr...@fred.mathworks.com>...
>
> > >         fprintf (fid,'%1.1\n',SLICE_H);
>
> > It miss something important in the format string. 'f', 'g', 'e'?
>
> > Bruno
>
> really? i only want to copy the data of slice_H() into sliceHp.txt

Yes. Check out the format specifiers in the documentation
of FPRINTF. You need what the docs call a 'conversion
character.'

Rune

Subject: Problem with fprintf

From: Nico zanette

Date: 14 Jul, 2009 10:16:02

Message: 5 of 6

Rune Allnor <allnor@tele.ntnu.no> wrote in message <3afb89a2-f8eb-409d-a322-0ada09f67edb@f33g2000vbm.googlegroups.com>...
> On 14 Jul, 12:03, "Nico zanette" <zannak...@hotmail.com> wrote:
> > "Bruno Luong" <b.lu...@fogale.findmycountry> wrote in message <h3hash$fr...@fred.mathworks.com>...
> >
> > > > ? ? ? ? fprintf (fid,'%1.1\n',SLICE_H);
> >
> > > It miss something important in the format string. 'f', 'g', 'e'?
> >
> > > Bruno
> >
> > really? i only want to copy the data of slice_H() into sliceHp.txt
>
> Yes. Check out the format specifiers in the documentation
> of FPRINTF. You need what the docs call a 'conversion
> character.'
>
> Rune

Thanks, i think i've solved my problem. now the txt file has the same number of byte of SLICE_H and it is a singol column data file

THnaks bruno
bye

Subject: Problem with fprintf

From: Bruno Luong

Date: 14 Jul, 2009 10:20:18

Message: 6 of 6

"Nico zanette" <zannakill@hotmail.com> wrote in message <h3hl4p$24u$1@fred.mathworks.com>...

>
> really? i only want to copy the data of slice_H() into sliceHp.txt


for i=1:10
fprintf('\nWhen I''m lazy to read the doc and forget my ''f'': %3.3\n', pi)
fprintf('\nWhen I don''t and stop asking ''really'': %3.3f\n', pi)
end

Bruno ;-)

Tags for this Thread

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.

rssFeed for this Thread

Contact us at files@mathworks.com