call recursive fun. erase txtfile
Show older comments
hi, I i have recursive function , each time call this function return different array.
I want to print these arrays into txt file, it is important to me store all arrays. But the problem each time is called function will erase the txtfile.
What I have to do to save all arrays?
THANKS IN ADVANCCE
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 9 Sep 2012
maby your fclose(fid) is in the loop
fid = fopen('filename.txt', 'w');
for k=1:10
v=(1:k), %example
fprintf(fid, '%f\t',v);
fprintf(fid, '\n',[]);
end
fclose(fid);
5 Comments
huda nawaf
on 9 Sep 2012
huda nawaf
on 9 Sep 2012
Azzi Abdelmalek
on 9 Sep 2012
if you post your function, it will be helpfull
Azzi Abdelmalek
on 9 Sep 2012
Edited: Azzi Abdelmalek
on 9 Sep 2012
I think you can add this code inside your function just after cluster1
fprintf(fid, '%f\t',cluster1);
fprintf(fid, '\n',[]);
and call your function
fid = fopen('filename.txt', 'w');
F=devide();
fclose(fid);
huda nawaf
on 11 Sep 2012
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!