Suppression failure on evalin command
4 次查看(过去 30 天)
显示 更早的评论
I'm having a problem suppressing the evalin function when using it to change elements in a vector. The semi-colon isn't working. Is there a fix for this? Here's an example:
>> i=zeros(1,4);
>> evalin('base','i(1)=1');
i =
1 0 0 0
The semicolon doesn't suppress the output for some reason.
0 个评论
采纳的回答
Mischa Kim
2014-11-28
编辑:Mischa Kim
2014-11-28
Ian, put the semi-colon right after the i(1)=1 statement
evalin('base','i(1)=1;')
0 个评论
更多回答(2 个)
Jan
2017-8-11
编辑:Jan
2017-8-12
It would be much more simple and efficient to omit the indirection over evalin:
i(1) = 1;
See the excellent explanations at tutorial:why-variables-should-not-be-named-dynamically-eval . You find a detailed analysis of the problems evalin causes here at: Answers: is-there-the-more-elegant-way-to-do-this#comment_476583
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!