clc; fprintf('Chuong trinh mo phong chuyen dong cua electron\n') dentat=10^(-10); q=1.6*10^(-19); me=9.109*10^(-31); %Nhap chieu dai ong d=input('Moi ban nhap vao chieu dai cua ong (cm)\n'); while d>200 fprintf('Do dai ban nhap qua lon!\n') fprintf('Xin hay nhap chieu dai trong khoang tu 100cm den 200cm\n') d=input('Moi ban nhap vao chieu dai cua ong (cm)\n'); end while d<100 fprintf('Do dai ban nhap qua nho!\n') fprintf('Xin hay nhap chieu dai trong khoang tu 100cm den 200cm\n') d=input('Moi ban nhap vao chieu dai cua ong (cm)\n'); end d=d/100;%doi don vi ra met %Nhap ban kinh ong r=input('Moi ban nhap vao ban kinh cua ong (cm)\n'); while r>20 fprintf('Ban kinh ban nhap qua lon!\n') fprintf('Xin hay nhap ban kinh trong khoang tu 10cm den 20cm\n') r=input('Moi ban nhap vao ban kinh cua ong (cm)\n'); end while r<10 fprintf('Ban kinh ban nhap qua nho!\n') fprintf('Xin hay nhap ban kinh trong khoang tu 10cm den 20cm\n') r=input('Moi ban nhap vao ban kinh cua ong (cm)\n'); end r=r/100;%doi don vi ra met V=input('Moi ban nhap vao dien the cua ong (v)\n'); while V>500 fprintf('Dien the ban nhap qua lon!\n') fprintf('Xin hay nhap dien the trong khoang tu 100v den 500v\n') V=input('Moi ban nhap vao dien the cua ong (v)\n'); end while V<100 fprintf('Dien the ban nhap qua nho!\n') fprintf('Xin hay nhap dien the trong khoang tu 100v den 500v\n') V=input('Moi ban nhap vao dien the cua ong (v)\n'); end E=V/d; F=q*E; x(1)=0; vantoc(1)=0; chieudai(1)=0; n=2; tam=chieudai(1); lap=0; while lap<=10 y=randint(1,1,[0,2*r*100])/100; y1=randint(1,1,[0,2*r*100])/100; y2=randint(1,1,[0,2*r*100])/100; while tam<=d vantoc(n)=(dentat*F)/me+vantoc(n-1); x(n)=dentat*vantoc(n)+x(n-1); chieudai(n)=chieudai(n-1)+x(n); tam=chieudai(n); plot(chieudai(n),y,'r .') plot(chieudai(n),y1,'b .') plot(chieudai(n),y2,'g .') axis([0 d 0 2*r]) title('Chuyen dong cua dien tu trong ong co dien truong') xlabel('chieu dai (m)'),ylabel('duong kinh ong (m)') pause(0.001) n=n+1; end lap=lap+1; x(1)=0; vantoc(1)=0; chieudai(1)=0; n=2; tam=chieudai(1); end . clc; fprintf(&apos ;Chuong trinh mo phong chuyen dong cua electron n') dentat=10^ (-1 0); q=1.6*10^ (-1 9); me=9.109*10^ (-3 1); %Nhap chieu dai ong d=input('Moi ban nhap vao chieu dai cua ong (cm)
'); while. 200cm
') d=input('Moi ban nhap vao chieu dai cua ong (cm)
'); end d=d/100;%doi don vi ra met %Nhap ban kinh ong r=input('Moi ban nhap vao ban kinh cua ong (cm)
'); while. 10cm den 20cm
') r=input('Moi ban nhap vao ban kinh cua ong (cm)
'); end r=r/100;%doi don vi ra met V=input('Moi ban nhap vao dien the cua ong (v)
'); while V>500