Suppression failure on evalin command

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.

 채택된 답변

Mischa Kim
Mischa Kim 2014년 11월 28일
편집: Mischa Kim 2014년 11월 28일

0 개 추천

Ian, put the semi-colon right after the i(1)=1 statement
evalin('base','i(1)=1;')

추가 답변 (2개)

Jan
Jan 2017년 8월 11일
편집: Jan 2017년 8월 12일

1 개 추천

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
Ian
Ian 2014년 11월 28일

0 개 추천

So simple, yet so effective. Thanks!

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

Ian
2014년 11월 28일

편집:

Jan
2017년 8월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by