How can i assign variable in program.
显示 更早的评论
a = [a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20];
assignin('base','a1',x(1));
assignin('base','a2',x(2));
assignin('base','a3',x(3));
assignin('base','a4',x(4));
assignin('base','a5',x(5));
assignin('base','a6',x(6));
assignin('base','a7',x(7));
assignin('base','a8',x(8));
assignin('base','a9',x(9));
assignin('base','a10',x(10));
assignin('base','a11',x(11));
assignin('base','a12',x(12));
assignin('base','a13',x(13));
assignin('base','a14',x(14));
assignin('base','a15',x(15));
assignin('base','a16',x(16));
assignin('base','a17',x(17));
assignin('base','a18',x(18));
assignin('base','a19',x(19));
assignin('base','a20',x(20));
x
1 个评论
In most cases assignin should be avoided for more effiicent ways of passing data between workspaces. The documentation states " Best Practice: Passing Arguments The most secure way to extend the scope of a function variable is to use function input and output arguments, which allow you to pass values of variables."
Numbered variables are a sign that you are doing something wrong.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!