The function of eval_r () is to treat the strings in parentheses as statements and run them.
For example:Eval_r ('y1 = sin (2) ') is equivalent to inputting the Y1 = sin (2) command in the MATLAB command window.
You can operate on variables or files with rules for multiple names,
Example 1:
For x = 1:5
Eval_r (['y', num2str (x), '=', num2str (x ^ 2), ';'])
End
The preceding statement is equivalent to executing the following five sentences:
Ynum2str (1) = num2str (1 ^ 2 );
Ynum2str (2) = num2str (2 ^ 2 );
Ynum2str (3) = num2str (3 ^ 2 );
Ynum2str (4) = num2str (4 ^ 2 );
Ynum2str (5) = num2str (5 ^ 2 );
Example 2:
Subplot (711); plot (T, Y); Title ('original sign ');
For I = 1:6
Subplot (7,1, I + 1 );
Plot (T, IMF (I ,:));
Eval_r (['title (''imf ', int2str (I), ''');']);
End
-------------------------
The above six lines of code actually execute the following seven commands:
Subplot (711); plot (T, Y); Title ('original sign ');
Subplot (7,1, 2); plot (T, IMF (1, :)); Title ('imf1 ');
Subplot (7,1, 3); plot (T, IMF (2, :)); Title ('imf2 ');
Subplot (7,1, 4); plot (T, IMF (3, :)); Title ('imf3 ');
Subplot (7,1, 5); plot (T, IMF (4, :)); Title ('imf1 ');
Subplot (7,1, 6); plot (T, IMF (5, :)); Title ('imf5 ');
Subplot (7,1, 7); plot (T, IMF (6, :)); Title ('imf6 ');
The last six statements are executed through the loop.
Here we use the e v a l () function to implement the output title ('imfi '); this statement
1. View title ('imf as a string
2. output the floating-point variable I (I =,) as a character.
3. Think of '); As a string
The above three parts are the output commands.Title ('imfi ');
It is worth noting that you want to output a single marker and replace it with '', just as the C language uses \ instead of \, which is a special symbol.
References
Http://zhidao.baidu.com/question/122921390.html? Fr = ala0