title: Matlab code checker
body: <p>I am doing a program for students. They can load their matlab code in the matlab program, and the program is supposed to execute the student's code and check if the output is correct, and if is not, the program must point out the wrong line code. So I think this is a kind of metaprogramming. Right now I am trying to use the eval() function in order to execute the input text as code, but I don't know if this is a good idea. Also I am having problems to maintain the variables in the workspace because when I change from one method to another, the workspace variables are reset, so I am thinking in solving this problem saving and loading the workspace in a file, but may be you can suggest other and better ideas.</p>
  
  <p>For now, we have predefined exercises the student must solve, the output of the program is always one or several images, because this is for image processing class. Here one example of code:</p>
  
  <pre><code>X=double(LENNA_G);
  Y=medfilt2(X,[7 7]);
  ps=psnr(Y,X,255);
  disp(sprintf('%f[dB]',ps));
  
  subplot(1,3,1);
  imagesc(X,[0 255]);
  colormap(gray(256))
  axis image
  
  subplot(1,3,2);
  imagesc(Y,[0 255]);
  axis image
  
  subplot(1,3,3);
  imagesc(X-Y,[-10 10]);
  axis image
  </code></pre>
  
  <p>After executing code, the resulting images are compared to correct images (predefined images), and must be the same. If they are not, then the program must point out at least the line of code in which the error could be. I don't know if I made my self understood =/.</p>
  
  <p>Thank you in advance.</p>