Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to express printf in matlab
How to express printf in matlab
1, we must first know how to use the print format variable of sprint function in matlab, similar to printf in C language. You can learn how to use the sprintf function by typing help sprintf in the command line window.

2. Let's look at an example using the sprintf function. Enter a=[ 1.256 2.356 4.789] in the command line window, press enter, enter sprintf('%.2f', a), and output to two decimal places in a matrix format.

3. It can be seen that all elements of matrix A are formatted and output two decimal places.

4. If we want to output a string, we can use sprintf('%s', b) format.

5. After pressing Enter, you can see that the output is the string matrix B..