简体   繁体   中英

Meaning of specific MATLAB instruction num2str

I have been sent some complete MATLAB script. It appears that author of this code has made a specific instruction using num2str and set_param . What is the purpose of the following line:

['[' num2str(operating_point) ']']

I am interested specially of an intention of using '[' as syntax.

set_param(system_block_name, operating_point_name,...
        ['[' num2str(operating_point) ']']

In MATLAB rectangular braces [] create vector/matrix. By default, horizontal vector of strings concatenated into 1 string:

['str1','str2'] % produces str1str2

So

['[',']'] % will print []

num2str() converts number into string:

a=10;
my_str = ['[',num2str(a),']'] % will assign my_str = '[10]'

set_param() is some function that gets 3 parameters, where 3rd one is your string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM