0

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);]); 
4

1 回答 1

1

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.

于 2016-04-11T17:52:30.683 回答