Please enable JavaScript to view this site.

Knowledge Base

Navigation: Scripting Language > Functions

num2str

We've made some changes. Use 'Ctrl-F5' to clear your browser cache.
Scroll Prev Top Next More

Converts an integer, floating point number, or matrix into a string. Matrices can only be 1D or 2D. Use the format script command to change the precision of the output.

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 

Syntax

Description

out = num2str(x);

Converts the number x into a string. x can also be a 1D or 2D matrix. The tab character (rather than space) will be used as delimiter between columns.

 

Example

Convert the number pi into a string.

format long;

?num2str(pi);

3.141592653589793

 

Convert a 2D matrix into a string and write to a text file.

X=meshgridx(1:2,1:3);

?num2str(X);

write("filename.txt",num2str(X));

1        1        1

2        2        2

 

See Also

Operators, ", +, ?, endl, write, format, str2num, findstring, replace, replacestring, substring, eval, lower, upper, toscript

Copyright Lumerical Inc. | Privacy | Site Map