Eval with multiple lines
12 ビュー (過去 30 日間)
古いコメントを表示
I have to run following with eval function in a single line.
a = 1:20; % first step is to define a variable
b = '[nan a(2:end)]'; % then index should be used. This should be in a single line.
c = eval(b);
My proposal is (which is wrong);
>> b = 'a = 1:20; [nan a(2:end)]'; % I need a single line such this
>> c = eval(b)
Error: The expression to the left of the equals sign is not a
valid target for an assignment.
There are some suggestions not to use eval. I have to use. Any help apreciated!
0 件のコメント
採用された回答
Walter Roberson
2015 年 10 月 29 日
You cannot return a value from eval().
Does the assignment specifically require you to use eval()? We firmly discourage the use of eval().
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Argument Definitions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!