The uses of fprintf and sprintf?

What are the exact uses for fprintf and sprintf? How do the two command differ and how should I know which command to use? Also using such a command to create a .txt file.

1 Kommentar

per isakson
per isakson am 15 Feb. 2015
Bearbeitet: per isakson am 15 Feb. 2015
The one creates a string in the work space the other prints to a file or the command window. The details are in the documentation.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Stephen23
Stephen23 am 16 Feb. 2015
Bearbeitet: Stephen23 am 22 Mai 2015

6 Stimmen

Some background: the name "printf" comes from "PRINT Formatted" and occurs in many programming languages. In MATLAB this is extended with the two versions:
  • fprintf means "File PRINT Formatted": use this for printing text to a file or the command window.
  • sprintf means "String PRINT Formatted": use this for creating a MATLAB string ( character vector ).

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 15 Feb. 2015

Bearbeitet:

am 22 Mai 2015

Community Treasure Hunt

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

Start Hunting!

Translated by