function f=fkrit(a,y_orig)
global l;
load_system('model');

set_param('model/PMSM1','Ld',mat2str(a(1)));
set_param('model/PMSM1','Rs',mat2str(a(2)));

  sim('model');
  % MSE to be minimized
  f = sum((Id_model-(y_orig))' * (Id_model-(y_orig))) / l;

