MATLAB Write result to txt file

  • Context: MATLAB 
  • Thread starter Thread starter NoobixCube
  • Start date Start date
  • Tags Tags
    File Matlab
Click For Summary

Discussion Overview

The discussion revolves around how to write results from a MATLAB program to a text file. Participants explore various methods for saving outputs, including the use of specific commands and techniques for handling multiple outputs generated by loops.

Discussion Character

  • Technical explanation, Homework-related

Main Points Raised

  • One participant inquires about writing results to a text file in MATLAB, expressing difficulty in finding a solution.
  • Another participant suggests using the save command for saving variables and the fprintf command for formatted output.
  • A different participant acknowledges the suggestion and expresses intent to explore it further.
  • One participant recommends searching for "MATLAB file io" for additional resources.
  • A participant reiterates the need to save multiple outputs from a for loop into a single text file, emphasizing the challenge of handling numerous outputs.
  • Another participant provides guidance on concatenating numbers into an array for saving, while also mentioning the use of fprintf for other types of outputs.

Areas of Agreement / Disagreement

Participants present various methods and suggestions, but there is no consensus on a single approach, as multiple techniques are discussed without resolution on the best method.

Contextual Notes

Some responses depend on the specific types of outputs being handled, and there are references to commands that may require further exploration for proper implementation.

NoobixCube
Messages
154
Reaction score
0
Hey All,
Quick question hope someone can help.
Does anyone know how to write the result from a program in MATLAB to a text file ?
I have googled this question to no avail.
:confused:
 
Physics news on Phys.org
If you want to save variables to a text file, try the save command.

For formatted output, try the fprintf command
 
Cheers siddharth I will have a gander.
 
you can search google by the keyword : MATLAB file io
then ,you will get the result you wanted
 
i want to save my output in text file. i use for loop so it produce n outputs.i want to save all the output in my single file
 
sivagami said:
i want to save my output in text file. i use for loop so it produce n outputs.i want to save all the output in my single file

Welcome to PhysicsForums!

If your outputs are numbers, concatenate your numbers together into an array and then save using the save command (type 'help save' to figure out how to get ASCII output). Otherwise, you'll need to use fprintf.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K