%It is presumed that QuickField is already started, the problem coil.pbm is opened. %The plunger is placed in x=0 position %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); hold all while (t_timex_in) %electromagnetic force theForce = getQfForceX(x_position); %add spring force theForce = theForce + (x_spring_free - x_position)*k; %calculate acceleration and speed v_speed = v_speed + theForce/m_mass * dt_time_step; %calculate plunger position x_position = x_position + v_speed * dt_time_step; t_time = t_time + dt_time_step; %plot x-position plot(t_time,x_position,'-or','MarkerSize',2); hold all end %add axis labels and title to the plot xlabel('Time t, sec.'); ylabel('Position x, m'); title('Plunger position vs. time');