% FILE: MVV.M % DONE BY: Reno Cipolla % DATE: OCT/93 % VERSION 2.0 % COPYRIGHT 1995 T. Marlin and R. Cipolla %This is a function file which calculates the MV violation. % *************************************************************** function violate = mvv(boundd,vpp); % Set all menu variables to global which allows them to be passed from mfile % to mfile. global tau1 tau2 tau3 Kp set deltat dist vp time pv Dyn junk2 rho1 obj distg global tdist D change tset SP t usegrh maxit IAE ISE ITAE tmg boundg violates global cn_t scn_t bound mvtest betaa Kn A useopt td maxdev mindev rise rho chg global epsl p pp bdpos bdneg bd kc ti bgen Xmis vpmis bdmis Kpp ob_j op_ts lim_it global Qp mm theta taulead xi thetad tauleadd xid taud1 taud2 taud3 Kpd x_ ver_sion global c_1 c_2 c_i b_1 b_2 b_i int_kc int_ti o_func le_vel numlev global ss ss1 ss2 ss3 v v1 v2 v3 al_pha save_graph ct_count violate = 0; l= betaa /deltat; while l < (time/deltat) l=l+1; if boundd(l) <= 0 if (vpp(l) < boundd(l)) violate = violate + (abs(vpp(l)) - abs(boundd(l)))^2; end else if (vpp(l) > boundd(l)) violate= violate +(vpp(l)-boundd(l))^2; end end end % end while