From: GAURAV on 21 Jun 2010 16:31 Hi Everyone! I have a variable a which contains 3 integer points [x y z]. Now I have a loop running and I will have many sets of points. So effectively, I will write down one set of points in file, run my code and append another set of points to it. I hope this makes sense. I need to write these to a file( mat, txt or any format) in this fashion:- x1 y1 z1 ( now append x2 y2 z2 to it) x2 y2 z2 ( go on appending) x3 y3 z3 .... .. .. xn yn zn.. How to do this? Please help me out. Thank You, Gaurav.
From: TideMan on 21 Jun 2010 16:34 On Jun 22, 8:31 am, "GAURAV " <gsha...(a)engineering.uiowa.edu> wrote: > Hi Everyone! > > I have a variable a which contains 3 integer points [x y z]. Now I have a loop running and I will have many sets of points. So effectively, I will write down one set of points in file, run my code and append another set of points to it. I hope this makes sense. > I need to write these to a file( mat, txt or any format) in this fashion:- > > x1 y1 z1 ( now append x2 y2 z2 to it) > x2 y2 z2 ( go on appending) > x3 y3 z3 > ... .. .. > xn yn zn.. > > How to do this? Please help me out. > > Thank You, > Gaurav. help fopen help fprintf help fclose Once you open the file, fprintf will append until you close the file.
From: Andy on 21 Jun 2010 16:43 "GAURAV " <gsharda(a)engineering.uiowa.edu> wrote in message <hvoi6o$5od$1(a)fred.mathworks.com>... > Hi Everyone! > > I have a variable a which contains 3 integer points [x y z]. Now I have a loop running and I will have many sets of points. So effectively, I will write down one set of points in file, run my code and append another set of points to it. I hope this makes sense. > I need to write these to a file( mat, txt or any format) in this fashion:- > > x1 y1 z1 ( now append x2 y2 z2 to it) > x2 y2 z2 ( go on appending) > x3 y3 z3 > ... .. .. > xn yn zn.. > > How to do this? Please help me out. > > Thank You, > Gaurav. Also, most writing functions have a way to do this. (For example, there are options in both xlswrite and dlmwrite that let you specify an offset. So you could keep track of which row you're writing and append that way.) But it would likely be much faster to create an array of data in MATLAB and write to a file only once.
From: us on 21 Jun 2010 16:44 "GAURAV " <gsharda(a)engineering.uiowa.edu> wrote in message <hvoi6o$5od$1(a)fred.mathworks.com>... > Hi Everyone! > > I have a variable a which contains 3 integer points [x y z]. Now I have a loop running and I will have many sets of points. So effectively, I will write down one set of points in file, run my code and append another set of points to it. I hope this makes sense. > I need to write these to a file( mat, txt or any format) in this fashion:- > > x1 y1 z1 ( now append x2 y2 z2 to it) > x2 y2 z2 ( go on appending) > x3 y3 z3 > ... .. .. > xn yn zn.. > > How to do this? Please help me out. > > Thank You, > Gaurav. hmm(?)... one of the very many solutions fnam='foo.res'; % <- your file name... nr=5; % <- #runs... p=zeros(nr,3); % <- pre-allocate... p(1,:)=[1,1,1]; % <- an initial condition... for i=2:5 p(i,:)=p(i-1,:)+[1,1,1]; end disp(p); %{ %} save(fnam,'p','-ascii'); type(fnam); %{ 1.0000000e+000 1.0000000e+000 1.0000000e+000 2.0000000e+000 2.0000000e+000 2.0000000e+000 3.0000000e+000 3.0000000e+000 3.0000000e+000 4.0000000e+000 4.0000000e+000 4.0000000e+000 5.0000000e+000 5.0000000e+000 5.0000000e+000 %} us
From: GAURAV on 22 Jun 2010 03:29 Thanks a lot for your help!
|
Pages: 1 Prev: This installer must be rung from disk #1 Next: Constraint in Implementing fsolve.m |