Example 3 – Euler’s Method delta = 0.4606 delta_arr(1)= .4606 x(1)=.01 deltaw = 0 delta_t=.01 f0 = 60 H=5 Pm=0.8 Pe1=.65 Pe2=1.465 Pa= Pm - Pe1*sin(delta) ddel_dt = deltaw ddel_dto=ddel_dt dwdt = pi*f0*Pa/H dwdto=dwdt a=1 t=0 while t<=0.3 deltan_p = delta + ddel_dt * delta_t deltawn_p = deltaw + dwdt* delta_t Pa= Pm - Pe1*sin(deltan_p) ddel_dt= deltawn_p dwdt= pi*f0*Pa/H delta= delta + ((ddel_dt+ddel_dto)/2)*delta_t deltaw= deltaw +((dwdt+dwdto)/2)*delta_t delta_arr(a)= delta dwdto=dwdt ddel_dto=ddel_dt t=t+.01 a=a+1 x(a)=x(a-1)+.01 end while t<=1 deltan_p = delta + ddel_dt * delta_t deltawn_p = deltaw + dwdt* delta_t Pa= Pm - Pe2*sin(deltan_p) ddel_dt= deltawn_p
dwdt= pi*f0*Pa/H delta= delta + ((ddel_dt+ddel_dto)/2)*delta_t deltaw= deltaw +((dwdt+dwdto)/2)*delta_t delta_arr(a)= delta dwdto=dwdt ddel_dto=ddel_dt t=t+.01 a=a+1 x(a)=x(a-1)+.01 end a=1:1:100 plot(x(a), delta_arr(a)) grid on Output Plot