%It is presumed that QuickField is already started, the problem coil.pbm is opened. pkg load windows %load windows package to enable COM %relay parameters x_out = 0.010; %pull out position. m x_in = 0.006; %pull in position, m m_mass = 0.0045; %plunger weight, kg k = 4; %spring constant, N/m x_spring_free = 0.015; %spring free would be position, m %initial conditions t_time = 0; %time, s x_position = x_out; %plunger position, m v_speed = 0; %plunger speed, m/s %integration time step, s dt_time_step = 0.005; %maximal integration time, s max_time = 0.2; %plot initial position plot(t_time,x_position,'-or','MarkerSize',2); %add axis labels and title to the plot xlabel('Time t, sec.'); ylabel('Position x, m'); title('Plunger position vs. time'); hold all while (t_timex_in) theForce = getQfForceX(x_position); %electromagnetic force theForce += (x_spring_free - x_position)*k; %add spring force v_speed += theForce/m_mass * dt_time_step; %calculate acceleration and speed x_position += v_speed * dt_time_step; %calculate plunger position t_time += dt_time_step; %plot x-position plot(t_time,x_position,'-or','MarkerSize',2); hold all end