Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to write symbols such as spaces, tabs, carriage returns and line breaks with fprintf in matlab?
How to write symbols such as spaces, tabs, carriage returns and line breaks with fprintf in matlab?
Space is space.

This tab is \t

Carriage return and line feed are \n

(In windowing systems, hyphens are usually used for carriage returns and line feeds \r\n)

For example:

The fprintf () function, such as

x = 0:. 1: 1;

a =[x; exp(x)];

fileID = fopen('exp.txt ',' w ');

fprintf(fileID,' %6s % 12s\n ',' x ',' exp(x)');

fprintf(fileID,' %6.2f % 12.8f\n ',A);

fclose(fileID);

In this example, the \ n of fprintf (fileid,'% 6.2f% 12.8f \n', a) is a line break.

Extended data:

Matlab includes control statements, functions, data structures, input and output and object-oriented programming. Users can synchronize the input statement with the execution command in the command window, or write a large and complex application (M file) before running together. The new version of MATLAB language is based on the most popular C++ language, so its grammatical features are very similar to C++ language, and it is simpler and more in line with the writing format of mathematical expressions of scientific and technical personnel.

It is more convenient for non-computer professionals to use it. Moreover, this language has strong portability and expansibility, which is also an important reason why MATLAB can go deep into various fields of scientific research and engineering calculation.

Baidu encyclopedia -MATLAB