matlabevalcommand-window

Matlab Eval function keeps returning information to command window


A part of my script consists of the following two codes, but for some reason the eval function is still returning information to the command window. As you can see I use a semicolon at the end of the lines but I'm guessing it is not placed right.

eval(['Norm_Accelerance' num2str(i0) ' = (Interp_accelerance-min(Interp_accelerance))/(max(Interp_accelerance)-min(Interp_accelerance));']);


eval(['Average_Norm_Accelerance = Average_Norm_Accelerance + Norm_Accelerance' num2str(i);]); 

Solution

  • With an eval statement, you need the semi-colon in the string. Your first line has this so that one should not be printing any values. The second one is missing that trailing semi-colon. You have one there, it's just a semi-colon and not a string containing a semi-colon. The second line should instead look like this:

    eval(['Average_Norm_Accelerance = Average_Norm_Accelerance + Norm_Accelerance' num2str(i) ';']); 
    

    More importantly, do not use eval. Even The Mathworks says it's a bad idea.