MATLAB Answers

How can i save the output of a matrix to a text file within loop

1 view (last 30 days)
Hassaan Mustafa
Hassaan Mustafa on 5 Oct 2012
Hello Sir, i am having a question regarding dlmwrite ... is it possible to use dlmwrite within a loop to save results in text file each time with new file name.
what i am doing is taking several thousands inputs , for which i used looping method, within loop, a file is taken as input and then apply some functions and bla bla stuff of DSP applied over it, and output comes which is stored in a variable called as "D" ... that output is in the form of "m x m" matrix (Square matrix) and i want to save that result in a txt file. and the loop goes on to the next input... can you tell me how to do so
to do it on a single file, without using loop, i am doing this in by this manner
%function here some long calculation which leads to results in a matrix called D
now that works fine for a single file without loop. Now can you give some guidelines regarding saving within loop, Like
- loop starts, (I've done this)
- read the file, (I've done this)
- apply the function, (I've done this)
- store results in variable "D" (I've done this)
- that result saves in text file whose name is the same name of the input file but extension be text ( not able to solve this riddle)
- display the result (I've done this)
- go to next file (I've done this)
Thanking in regards.
P.S. I've tried save and fprintf, but i am not able to achieve the desired results.
  1 Comment
Hassaan Mustafa
Hassaan Mustafa on 5 Oct 2012
Sorry, i forget to mention, my all results are in the form of binary and i have to keep the results in binary for further stages

Sign in to comment.

Answers (0)



Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by