clc;clear all;close all; ti=0:2:46; % Thoi gian do Tps=17; % Nhiet do phong Ts=68.8 64.8 62.1 59.9 57.7 55.9 ... 53.9 52.3 50.8 49.5 48.1 46.8 ... 45.9 44.8 43.7 42.6 41.7 40.8 ... 39.9 39.3 38.6 37.7 37.0 36.4; % Nhiet do thuc nghiem % Lap phuong trinh nguoi theo dinh luat nguoi thu I cua Newton T=dsolve(DT=r(TTp),T(0)=T0,t); % dsolve =>Tim no giai tich cua ptvp thuong % DT=dTdt % r : hang so nguoi % T : nhiet do cua vat % Tp : Nhiet do moi truong % t : thoi gian disp(Bieu thuc T tinh duoc: ); pretty(T) % pretty : Bieu dien dang tu nhien cua bien sym => lam dep syms r Tp T0 t % xac dinh hang so nguoi cua coc cafe bang tay(gan dung) % nr=input(nhap hang so nguoi r= ); %nhap r=0.025 % Tcf=subs(T,{r,Tp,T0},{nr,Tps,Ts(1)}) % Tcfi=double(subs(Tcf,t,ti)); % plot(ti,Ts,+r,ti,Tcfi) % sau khi tim r gan dung phu hop voi duong thuc nghiem % tim r bang pphap xap xi phi tuyen symT=subs(T,{Tp,T0,r},{Tps,a(1),a(2)}); %subs=>Tinh gtri cua DTDS T f=inline(vectorize(symT),a,t); % vectorize=>Chuyen phep tinh ma tran sang phep tinh vector an,dan=lsqcurvefit(f,Ts(1),0.02,ti,Ts); % lsqcurvefit=>Chinh xac hoa an T0=an(1); r=an(2); Tp=17; disp(hang so nguoi ); r % tim thoi diem coc cafe dat 30do,50do btT=vpa(subs(T),5); % vpa(x,n)=>Tinh gt T (bien sym) voi do chinh xac n=5 chu so thap phan disp(bieu thuc T(t): ); pretty(btT) t30=double(solve(btT30)) %double dung de dua gtri syms => so t50=double(solve(btT50)) % ve do thi T(t) cung so lieu thuc nghiem: tii=0:2:70; figure(2) plot(ti,Ts,+r,tii,double(f(an,tii))); grid on; End Hang so nguoi cua coc cafe la r=0.021529 Cong thuc cua ndo theo thoi gian la: T(t)= 17. + 49.084 exp(0.021529 t) Thoi gian khi coc cafe tro thanh 30 do la t= 61.7114 Thoi gian khi coc cafe tro thanh 50 do t= 18.4414 BÀI 2: Giả sử quá trình nguội của cốc cafe sữa tuân theo định luật nguội của Newton suy rộng: DT=r2(TTf)2 r1(TTf), Tf=17 độ. Xác định hằng số nguội r của cốc cafê Tìm biểu thức nhiệt độ của cốc cafê sữa T theo time t Vẽ đồ thị biểu thức T(t) cùng với số liệu trong bảng Xác định khi nào nhiệt độ của cốc cafê đạt 30 và 50 độ o0o clc;clear all;close all; ti=0:2:46; % Thoi gian do nTf=17; % Nhiet do phong Ti=82.3 78.5 74.3 70.7 67.6 65.0 62.5 60.1 ... 58.1 56.1 54.3 52.8 51.2 49.9 48.8 47.2 ... 46.1 45.0 43.9 43.0 41.9 41.0 40.1 39.5; % Nhiet do thuc nghiem % lap phuong trinh nguoi theo dl suy rong cua Newton % r1, r2 : hang so nguoi cua T=dsolve(DT=r2(TTf)2r1(TTf),T(0)=T0,t); %dsolve=>Tim nghiem giai tich cua ptvp thuong disp(Bieu thuc T tinh duoc: ); pretty(T) % pretty : Bieu dien dang tu nhien cua bien sym syms r1 r2 Tf T0 t % tim r bang pphap xap xi phi tuyen symT=subs(T,{Tf,T0,r1,r2},{nTf,a(1),a(2),a(3)}); %subs=>Tinh gtri cua DTDS T f=inline(vectorize(symT),a,t); % vectorize=>Chuyen phep tinh ma tran sang phep tinh vector % Su dung dl I cua Newton de tim r1 sau do dung dl suy rong tim r2 a0=Ti(1),0.02,0; an,dan=lsqcurvefit(f,a0,ti,Ti); %Chinh xac hoa an T0=an(1); r1=an(2); r2=an(3); Tf=17; disp(hang so nguoi ); r1, r2 % Tim thoi diem coc cafe dat 30do,50do btT=vpa(subs(T),5); %vpa(x,n)=>Tinh gtrị T (biến sym) với độ cxac n (số chữ số thập phan) disp(bieu thuc T(t): ); pretty(btT) t30=double(solve(btT30)) t50=double(solve(btT50)) %ve do thi T(t) cung so lieu thuc nghiem: plot(ti,Ti,+r,ti,double(f(an,ti))); End Hang so nguoi cua coc cafe la r1= 0.0072 va r2= 4.2306e004 Cong thuc cua nhiet do theo thoi gian la: 0.000098876 + 0.59267 exp(0.0071936 t) 0.034863 exp(0.0071936 t) 0.027669 Thoi gian khi coc cafe tro thanh 30 do la t= 84.1375 Thoi gian khi coc cafe tro thanh 50 do t= 25.6440 CÁC BÀI TOÁN PHÂN HỦY HẠT NHÂN BÀI 3: Biết Kr phân hủy thành Br với thời gian bán rã T=14.8h. Br lại phân hủy thành Se với T=16.1h. Lúc đầu chỉ có 1mg Kr Khi nào Br có khối lượng lớn nhất và bằng bao nhiều? Khi nào Br có khối lượng bằng khối lượng Kr và bằng bao nhiều? Khi nào Br có khối lượng bằng khối lượng Se và bằng bao nhiều? o0o clc;clear all;close all; %Gan cac hang so ban ra va chu ky cua cac chat T12Kr=14.8; % Chu ky ban ra cua Kr T12Br=16.1; % Chu ky ban ra cua Br lKr=log(2)T12Kr; % hang so ban ra cua Kr (lamda=ln(2)T) lBr=log(2)T12Br; % hang so ban ra cua Br % Thiet lap ptvp (dNdt=lamdaN) % dN : So hat bi phan ra trong thoi gian dt % N : So hat con lai tai thoi dien t eq1=DNKr=lmKrNKr; % pt phan ra cua Kr, NKr ki hieu bien eq2=DNBr=lmKrNKrlmBrNBr; % pt phan ra cua Br eq3=DNSe=lmBrNBr; % pt phan ra cua Se eqs=eq1,,,eq2,,,eq3; % he pt phan ra int=NKr(0)=1,NBr(0)=0,NSe(0)=0; %dieu kien ban dau % Giai PT vi phan lay nghiem dsol=dsolve(eqs,int,t); %dsolve=>tim no gt cua ptvp: eqs, dkbd: int va bien doc lap: t syms lmKr lmBr t Kr=subs(dsol.NKr,{lmKr,lmBr},{lKr,lBr}); % lay nghiem NKr Br=subs(dsol.NBr,{lmKr,lmBr},{lKr,lBr}); Se=subs(dsol.NSe,{lmKr,lmBr},{lKr,lBr}); % Ve do thi bieu dien qua trinh phan ra theo thoi gian t fplot(char(Kr),0 200,r); hold on; fplot(char(Br),0 200,g); fplot(char(Se),0 200,:b); hold off; legend(Kr,Br,Se) % Xac dinh gia tri lon nhat cua Br dBr=diff(Br); %Tinh dao ham: disp(Thoi diem Br co khoi luong lon nhat: ); t1=double(solve(dBr)) disp(Khoi luong lon nhat cua Br la: ); Brmax=double(subs(Br,t,t1)) % Xac dinh thoi diem Br va Kr co khoi luong bang nhau: disp( Thoi diem Br va Kr co kl bang nhau : ); t2=double(solve(KrBr)) disp(khoi luong Kr va Br = ); mKr=double(subs(Kr,t,t2)) mBr=double(subs(Br,t,t2)) % Xac dinh thoi diem Br co khoi luong bang Se: t0,m0=ginput(1); t3,mSeBr=fsolve(inline(char(BrSe)),t0,optimset(display,off)); % fsolve=>chinh xac hoa nghiem gan dung t0 disp(Thoi diem Br co khoi luong bang Se: ); t3 disp(khoi luong Br va Se= ); mBr=double(subs(Br,t,t3)) mSe=double(subs(Se,t,t3)) End Nmax = 0.3835 Br co khoi luong lon khi: t = 22.2633h va bang : 0.38347mg Br co khoi luong bang Kr khi : t= 20.5336h va bang 0.3823mg Br co khoi luong bang Se khi : t= 28.7622h va bang 0.3700mg Bài 4: Biet Rn phan huy theo 2 cach( theo hinh ve) 211Rn>26%207Po>207Bi>207Pb 211Rn>74%At>211Po>207Pb o0o clc; clear all; close all; %Tinh cac hang so ban ra (h) TRn=15; LRn=log(2)TRn; %hang so ban ra cua Rn TAt=7.2; LAt=log(2)TAt; %hang so ban ra cua At TPo1=0.523600; LPo1=log(2)TPo1; %hang so ban ra cua Po211 TPo7=5.7; LPo7=log(2)TPo7; %hang so ban ra cua Po207 TBi=3036524; LBi=log(2)TBi; %hang so ban ra cua Bi % Thiet lap ptvp (dNdt=lamdaN) eq1=DNRn=LRnNRn; % pt phan ra cua Rn eq2=DNAt=LAtNAt+74100LRnNRn; %pt phan ra cua At eq3=DNPo1=LPo1NPo1+LAtNAt; %pt phan ra Po211 eq4=DNPo7=LPo7NPo7+26100LRnNRn; %phan ra ra 207Po eq5=DNBi=LBiNBi+LPo7NPo7; %PT phan ra 205Bi eq6=DNPb=LBiNBi+LPo1NPo1; %PT phan ra Pb eqs=eq1,,,eq2,,,eq3,,,eq4,,,eq5,,,eq6; % he pt phan ra int=NRn(0)=1,NAt(0)=0,NPo1(0)=0,NPo7(0)=0,NBi(0)=0,NPb(0)=0; % dieu kien ban dau % Giai PT vi phan lay nghiem sol=dsolve(eqs,int,t); %dsolve=>tim no gt cua ptvp: eqs, dkbd: int va bien doc lap: t
BÀI 1: QUÁ TRÌNH NGUỘI CỐC CAFE (BẬC 1) function baitoan1 clear all;clc;close all; T=dsolve('DT=-r*(T-Tp)','T(0)=T0','t'); fprintf('bieu thuc cua T theo t la: ');pretty(T); syms Tp T0 r t % T=Tp+(T0-Tp)*exp(-r*t); ti=0:2:46; Tcd=[82.3,78.5,74.3,70.7,67.6,65.0,62.5,60.1,58.1,56.1,54.3,52.8,51 2,49.9,48.6,47.2,46.1,45.0,43.9,43.0,41.9,41.0,40.1,39.5]; Tcs=[68.8,64.8,62.1,59.9,57.7,55.9,53.9,52.3,50.8,49.5,48.1,46.8,45 9,44.8,43.7,42.6,41.7,40.8,39.9,39.3,38.6,37.7,37.0,36.4]; plot(ti,Tcd,'*-r');hold on; grid on; ylabel('nhiet (do C)');xlabel('thoi gian(phut)'); title('qua trinh nguoi cua coc cafe den'); Td=subs(T,[Tp,T0],[17,82.3]); funTd=inline(vectorize(Td),'r','t'); r0d=0.025; rnd=lsqcurvefit(funTd,r0d,ti,Tcd); fprintf('hang so nguoi la'),rnd yyd=funTd(rnd,ti); plot(ti,yyd,'+-b'); legend('duong thuc nghiem','duong ly thuyet'); %tim thoi gian coc cafe co nhiet 50 va 30 Td=subs(Td,r,rnd); fprintf('bieu thuc nhiet T cua coc cafe theo thoi gian t la:');pretty(Td); figure(2); ezplot(Td,[0 80]);grid on; t50d=double(solve(Td-50)); fprintf('thoi gian de coc cafe co nhiet 50do la: '),t50d t30d=double(solve(Td-30)); fprintf('thoi gian de coc cafe co nhiet 30do la: '),t30d figure(3); plot(ti,Tcs,'*-r');hold on;grid on; ylabel('nhiet (do C)');xlabel('thoi gian(phut)'); title('qua trinh nguoi cua coc cafe sua'); Ts=subs(T,[Tp,T0],[17,68.8]); funTs=inline(vectorize(Ts),'r','t'); r0s=0.023; rns=lsqcurvefit(funTs,r0s,ti,Tcs); fprintf('hang so nguoi la'),rns yys=funTs(rns,ti); plot(ti,yys,'+-b'); legend('duong thuc nghiem','duong ly thuyet'); %tim thoi gian coc cafe co nhiet 50 va 30 Ts=subs(Ts,r,rns); fprintf('bieu thuc nhiet T cua coc cafe theo thoi gian t la:');pretty(Ts); figure(4); ezplot(Ts,[0 80]);grid on; t50s=double(solve(Ts-50)); fprintf('thoi gian de coc cafe co nhiet 50do la: '),t50s t30s=double(solve(Ts-30)); fprintf('thoi gian de coc cafe co nhiet 30do la: '),t30s % % % % % % % % % % % % % % % % bieu thuc cua T theo t la: Tp + exp(-r t) (-Tp + T0) hang so nguoi la: rnd =0.0259 bieu thuc nhiet T cua coc cafe theo thoi gian t la: 653 7471411333879989 17 + - exp(- t) 10 288230376151711744 thoi gian de coc cafe co nhiet 50do la:t50d =26.3287 thoi gian de coc cafe co nhiet 30do la:t30d = 62.2662 hang so nguoi la: rns = 0.0237 bieu thuc nhiet T cua coc cafe theo thoi gian t la: 3415481214600901 17 + 259/5 exp(- t) 144115188075855872 thoi gian de coc cafe co nhiet 50do la: t50s =19.0249 thoi gian de coc cafe co nhiet 30do la: t30s =58.3317 ####DẠNG KHÁC function baitoan1_2 clear all;clc;close all; T=dsolve('DT=-r*(T-Tp)','T(0)=T0','t'); disp('bieu thuc nhiet do: T(t)=');pretty(T); syms r T0 Tp t ti=0:2:46; while (1) k=menu('hang so nguoi','cafe den','cafe sua','thoat'); switch k case Tcd=[82.3,78.5,74.3,70.7,67.6,65.0,62.5,60.1,58.1,56.1,54.3,52.8,51 2,49.9,48.6,47.2,46.1,45.0,43.9,43.0,41.9,41.0,40.1,39.5]; figure(1); plot(ti,Tcd,'r');hold on;grid on; nr=input('cho gan dung ban dau r la: '); %0.025 Tcdt=subs(T,[r,T0,Tp],[nr,Tcd(1),17]); Tcdt=subs(Tcdt,t,ti); plot(ti,Tcdt,'b'); ylabel('nhiet (do C)');xlabel('thoi gian(phut)'); title('qua trinh nguoi cua coc cafe den'); legend('duong thuc nghiem',['duong ly thuyet voi r =', num2str(nr)]);hold off; case Tcs=[68.8,64.8,62.1,59.9,57.7,55.9,53.9,52.3,50.8,49.5,48.1,46.8,45 9,44.8,43.7,42.6,41.7,40.8,39.9,39.3,38.6,37.7,37.0,36.4]; figure(2); plot(ti,Tcs,'r');hold on;grid on; nr=input('cho gan dung ban dau r la: '); %0.023 Tcst=subs(T,[r,T0,Tp],[nr,Tcs(1),17]); Tcst=subs(Tcst,t,ti); plot(ti,Tcst,'b'); ylabel('nhiet (do C)');xlabel('thoi gian(phut)'); title('qua trinh nguoi cua coc cafe den'); legend('duong thuc nghiem',['duong ly thuyet voi r =', num2str(nr)]);hold off; case break end end BÀI 2: QUÁ TRÌNH NGUỘI CỐC CAFE (BẬC 2) function baitoan2 clear all;clc;close all; T=dsolve('DT=-r2*(T-Tp)^2-r1*(T-Tp)','T(0)=T0','t'); fprintf('bieu thuc cua T theo t la: ');pretty(T); syms Tp T0 r1 r2 t ti=0:2:46; Tcd=[82.3,78.5,74.3,70.7,67.6,65.0,62.5,60.1,58.1,56.1,54.3,52.8,51 2,49.9,48.6,47.2,46.1,45.0,43.9,43.0,41.9,41.0,40.1,39.5]; plot(ti,Tcd,'*-r');hold on; grid on; ylabel('nhiet (do C)');xlabel('thoi gian(phut)'); title('qua trinh nguoi cua coc cafe den'); Td=subs(T,{Tp,T0,r1,r2},{17,'a(1)','a(2)','a(3)'}); funTd=inline(vectorize(Td),'a','t'); r0d=[82.3 0.006 0.0004]; rnd=lsqcurvefit(funTd,r0d,ti,Tcd); %fprintf('hang so nguoi la:'),r1=rnd(2),r2=rnd(3) fprintf(['hang so nguoi r1= ',num2str(rnd(2)),' va r2= ',num2str(rnd(3)),'\n']); yyd=funTd(rnd,ti); plot(ti,yyd,'+-b'); legend('duong thuc nghiem','duong ly thuyet'); %tim thoi gian coc cafe co nhiet 50 va 30 Td=subs(Td,{'a(1)','a(2)','a(3)'},{rnd(1),rnd(2),rnd(3)}); %fprintf('bieu thuc nhiet T cua coc cafe theo thoi gian t la:');pretty(Td); fprintf(['bieu thu nhiet T cua coc cafe theo thoi gian t la: \n',char(vpa(Td,3)),'\n']); figure(2); ezplot(Td,[0 120]);grid on; t50d=double(solve(Td-50)); fprintf('thoi gian de coc cafe co nhiet 50do la: '),t50d t30d=double(solve(Td-30)); fprintf('thoi gian de coc cafe co nhiet 30do la: '),t30d % bieu thuc cua T theo t la: % r1 - r2 Tp + T0 r2 % r1 + Tp exp(t r1 + log(- )) - r2 Tp % Tp - T0 % - -% r1 - r2 Tp + T0 r2 % -exp(t r1 + log(- )) + r2 % Tp - T0 % hang so nguoi r1= 0.0071874 va r2= 0.00042365 % bieu thu nhiet T cua coc cafe theo thoi gian t la: % (.147e-4-17.*exp(.719e-2*t-7.54))/(-1.*exp(.719e-2*t-7.54)+.424e3) % thoi gian de coc cafe co nhiet 50do la: t50d =25.6294 % thoi gian de coc cafe co nhiet 30do la: t30d =84.1027 BÀI 3: PHÂN HỦY HẠT NHÂN Kr Br Se function baitoan3 clear all;clc;close all; T1=14.8;T2=16.1; % lamda1=log(2)/T1;lamda2=log(2)/T2; % d1='DN1=-ld1*N1'; % d2='DN2=-ld2*N2+ld1*N1'; % d3='DN3=ld2*N2'; % d=[d1,',',d2,',',d3]; % dkbd='N1(0)=1,N2(0)=0,N3(0)=0'; % dsol=dsolve(d,dkbd,'t'); % syms ld1 ld2 t % N1t=subs(dsol.N1,ld1,lamda1); % N2t=subs(dsol.N2,[ld1,ld2],[lamda1,lamda2]); % N3t=subs(dsol.N3,[ld1,ld2],[lamda1,lamda2]); ld1=log(2)/T1;ld2=log(2)/T2; d1='DN1=-ld1*N1'; d2='DN2=-ld2*N2+ld1*N1'; d3='DN3=ld2*N2'; d=[d1,',',d2,',',d3]; dkbd='N1(0)=1,N2(0)=0,N3(0)=0'; dsol=dsolve(d,dkbd,'t'); N1t=subs(dsol.N1); N2t=subs(dsol.N2); N3t=subs(dsol.N3); % ti=0:2:200; % N1ti=subs(N1t,t,ti); % plot(ti,N1ti,'r'); ezplot(N1t,[0 200]);hold on;grid on; h1=ezplot(N2t,[0 200]);set(h1,'color',[1 0]); h2=ezplot(N3t,[0 200]);set(h2,'color',[0 0]); title('qua trinh phan huy Kr'); legend('Kr','Br','Se'); ylabel('khoi luong (mg)'); xlabel('thoi gian (gio)'); %khi mBr max [x0,y0]=ginput(1); % n2ti=inline(['-1*(',vectorize(N2t),')'],'t'); n2ti=inline(vectorize(-N2t),'t'); [xn,yn]=fminsearch(n2ti,x0,optimset('display','off')); fprintf(['Br co khoi luong lon nhat la m= ',num2str(-yn),' tai t= ',num2str(xn),'\n']); %khi mBr=mKr [x01,y01]=ginput(1); n12ti=inline(vectorize(-N2t+N1t),'t'); [xn1,yn1]=fsolve(n12ti,x01,optimset('display','off')); fprintf(['Br co khoi luong bang Kr tai t= ',num2str(xn1),' mBr= ',num2str(-n2ti(xn1)),'\n']); %khi mBr=mSe [x02,y02]=ginput(1); n23ti=inline(vectorize(-N2t+N3t),'t'); [xn2,yn2]=fsolve(n23ti,x02,optimset('display','off')); fprintf(['Br co khoi luong bang Se tai t= ',num2str(xn2),' mBr= ',num2str(-n2ti(xn2)),'\n']); % Br co khoi luong lon nhat la m= 0.38347 tai t= 22.2634 % Br co khoi luong bang Kr tai t= 20.5336 mBr= 0.38225 % Br co khoi luong bang Se tai t= 28.763 mBr= 0.37 BÀI 4: PHÂN HỦY HẠT NHÂN THEO NHÁNH Rn Rn 26%Po 74%At Bi Po Pb Pb function baitoan4 clear all; clc; close all; TRn=15; TPo207=5.7; TBi=30*365*24; TAt=7.2; TPo211=0.52/3600; lRn=log(2)/TRn;lPo207=log(2)/TPo207;lBi=log(2)/TBi;lAt=log(2)/TAt;l Po211=log(2)/TPo211; f1='DNRn=-lRn*NRn'; f21='DNPo207=-lPo207*NPo207+26/100*lRn*NRn'; f31='DNBi=-lBi*NBi+lPo207*NPo207'; f22='DNAt=-lAt*NAt+74/100*lRn*NRn'; f32='DNPo211=-lPo211*NPo211+lAt*NAt'; f=[f1,',',f21,',',f31,',',f22,',',f32]; dkbd='NRn(0)=1, NPo207(0)=0, NBi(0)=0, NAt(0)=0, NPo211(0)=0'; dsol=dsolve(f,dkbd,'t'); NRnt=subs(dsol.NRn); NPo207t=subs(dsol.NPo207); NBit=subs(dsol.NBi); NAtt=subs(dsol.NAt); NPo211t=subs(dsol.NPo211); NPbt=1-(NRnt+NPo207t+NBit+NAtt+NPo211t); ti=linspace(0,100); subplot(3,2,1);ezplot(NRnt,[0 100]);grid on;title('Rn'); subplot(3,2,3);ezplot(NPo207t,[0 100]);grid on;title('Po207'); subplot(3,2,5);ezplot(NBit,[0 300]);grid on;title('Bi'); subplot(3,2,2);ezplot(NAtt,[0 100]);grid on;title('At'); subplot(3,2,4);NPo211i=double(subs(NPo211t,'t',sym(ti)));plot(ti,NP o211i);grid on;title('Po211'); subplot(3,2,6);NPbi=double(subs(NPbt,'t',sym(ti)));plot(ti,NPbi);gr id on;title('Pb'); %thoi diem cac nguyen to At,Po211,Po207 va Bi co khoi luong cuc dai NAti=inline(vectorize(-NAtt),'t'); [t0,m0]=ginput(1); [tn,mn]=fminsearch(NAti,t0,optimset('display','off')); fprintf(['At co khoi luong lon nhat la m= ',num2str(-mn),' tai t= ',num2str(tn),'\n']); NPo211i=inline(vectorize(-NPo211t),'t'); [t01,m01]=ginput(1); [tn1,mn1]=fminsearch(NPo211i,t01,optimset('display','off','tolfun', 1e-12,'tolx',1e-12)); %mn1=double(subs(NPo211i,'t',sym(tn1))); mn1=NPo211i(tn1); fprintf(['Po211 co khoi luong lon nhat la m= ',num2str(-mn1),' tai t= ',num2str(tn1),'\n']); NPo207i=inline(vectorize(-NPo207t),'t'); [t02,m02]=ginput(1); [tn2,mn2]=fminsearch(NPo207i,t02,optimset('display','off')); fprintf(['Po207 co khoi luong lon nhat la m= ',num2str(-mn2),' tai t= ',num2str(tn2),'\n']); NBii=inline(vectorize(-NBit),'t'); [t03,m03]=ginput(1); [tn3,mn3]=fminsearch(NBii,t03,optimset('display','off')); fprintf(['Bi co khoi luong lon nhat la m= ',num2str(-mn3),' tai t= ',num2str(tn3),'\n']); %Thoi diem mPb=1/3mRn va mPb=2/3mRn figure(2); NPb13Rn=inline(vectorize(NPbt-1/3*NRnt),'t'); NPb13Rni=double(subs(NPbt,'t',sym(ti))-1/3*subs(NRnt,'t',sym(ti))); plot(ti,NPb13Rni,'r');grid on;hold on; [tn130,mn130]=ginput(1); [tn13,mn13]=fsolve(NPb13Rn,tn130,optimset('display','off','tolfun', 1e-12,'tolx',1e-12)); mn13=double(subs(NPbt,'t',sym(tn13))); fprintf(['Pb co khoi luong bang 1/3Rn tai t= ',num2str(tn13),' mPb= ',num2str(mn13),'\n']); NPb23Rn=inline(vectorize(NPbt-2/3*NRnt),'t'); NPb23Rni=double(subs(NPbt,'t',sym(ti))-2/3*subs(NRnt,'t',sym(ti))); plot(ti,NPb23Rni,'b'); [tn230,mn230]=ginput(1); [tn23,mn23]=fsolve(NPb23Rn,tn230,optimset('display','off','tolfun', 1e-12,'tolx',1e-12)); mn23=double(subs(NPbt,'t',sym(tn23))); fprintf(['Pb co khoi luong bang 2/3Rn tai t= ',num2str(tn23),' mPb= ',num2str(mn23),'\n']); % % % % % % At co Po211 Po207 Bi co Pb co Pb co khoi luong lon nhat la m= co khoi luong lon nhat la co khoi luong lon nhat la khoi luong lon nhat la m= khoi luong bang 1/3Rn tai khoi luong bang 2/3Rn tai 0.1804 tai t= 14.6616 m= NaN tai t= 13.2432 m= 0.054602 tai t= 12.8336 0.25985 tai t= 221.8078 t= 13.9401 mPb= 0.17124 t= 19.2396 mPb= 0.26222 BÀI 5: NÉM XIÊN VỚI Fms = k.v function baitoan5 clear;close all;clc; m=0.1;h0=15;v0=30;alpha=pi/6;k=0.15;g=9.8; f1='D2x=-k/m*Dx'; f2='D2y=-k/m*Dy-g'; f=[f1,',',f2]; int='x(0)=0,Dx(0)=v0*cos(alpha),y(0)=h0,Dy(0)=v0*sin(alpha)'; fs=dsolve(f,int,'t'); x=subs(fs.x,{'m','h0','v0','alpha','k','g'},{m,h0,v0,alpha,k,g}); y=subs(fs.y,{'m','h0','v0','alpha','k','g'},{m,h0,v0,alpha,k,g}); vx=diff(x);vy=diff(y); subplot(2,2,1);ezplot(x,[0 4]);title('do thi x theo thoi gian');grid on; subplot(2,2,2);ezplot(y,[0 4]);title('do thi y theo thoi gian');grid on; subplot(2,2,3);ezplot(vx,[0 4]);title('do thi vx theo thoi gian');grid on; subplot(2,2,4);ezplot(vy,[0 4]);title('do thi vy theo thoi gian');grid on; figure(2); ezplot(x,y);title('do thi quy dao');grid on; axis([0 20 25]); %khi co ma sat vat di xa duoc xn tn=double(solve([char(y),'=0'],'t'));tn=tn(1,1); xn=subs(x,'t',tn); %khi khong co ma sat vat di xa duoc mot khoang la xn1 %thay doi lai cac dieu kien ban dau ko co ma sat f11='D2x=0'; f21='D2y=-g'; ff=[f11,',',f21]; fs1=dsolve(ff,int,'t'); tn1=double(solve([char(subs(fs1.y,{'m','h0','v0','alpha','k','g'},{ m,h0,v0,alpha,k,g})),'=0'],'t')); tn1=tn1(2,1); xn1=subs(subs(fs1.x,{'m','h0','v0','alpha','k','g'},{m,h0,v0,alpha, k,g}),'t',tn1); fprintf(['khi khong co ma sat vat se di xa them duoc mot khoang nua la: ',num2str(xn1-xn),'m\n']); %thoi diem va cao vat dat cao cuc dai figure(1); [t0,y0]=ginput(1); yinl=inline(vectorize(-y),'t'); [tmax,ymax]=fminsearch(yinl,t0,optimset('display','off')); fprintf(['do cao cuc dai cua vat la: h=',num2str(-ymax),'m',' tai thoi diem: t= ',num2str(tmax),'s\n']); %xac dinh goc nem toi uu de vat co the di xa nhat fx=subs(fs.x,{'h0','m','v0','k','g'},{h0,m,v0,k,g}); fy=subs(fs.y,{'h0','m','v0','k','g'},{h0,m,v0,k,g}); phi=linspace(-pi/2,pi/2,20); for i=1:length(phi) fy1=subs(fy,'alpha',phi(i)); fx1=subs(fx,'alpha',phi(i)); t1=double(solve([char(fy1),'=0'],'t')); for j=1:length(t1) if t1(j)>0 tmax=t1(j); end end xmax(i)=subs(fx1,'t',tmax); end sp=spline(phi,xmax); figure(3); fnplt(sp,[-pi/2 pi/2]);grid on; figure(3); [phi0,xmax0]=ginput(1); [phin,xmaxn]=fminsearch(@(phi)ppval(sp,phi),phi0,optimset('display','off')); fprintf(['goc nem toi uu la: phi= ',num2str(phin*180/pi),'do',' va xmax= ',num2str(-xmaxn),'m\n']); % khong co ma sat vat se di xa them duoc mot khoang nua la: 82.8627m % cao cuc dai cua vat la: h=19.8052m tai thoi diem: t= 0.79515s % goc nem toi uu la: phi= 2.5671do va xmax= 19.7866m BÀI 6: NÉM XIÊN VỚI Fms = k.v2 function baitoan6 clear all;close all;clc; m=0.1; h0=15; v0=30; alpha=pi/6; g=9.8; vth=6; k=m*g/vth^2; % u1=x; % u2=y; % u1'=u3=vx % u2'=u4=vy % u3'=-k/m*sqrt(u3^2+u4^2)*u3; % u4'=-k/m*sqrt(u3^2+u4^2)*u4; f=inline(['[u(3);u(4);',num2str(k/m),'*sqrt(u(3)^2+u(4)^2)*u(3);', num2str(-k/m),'*sqrt(u(3)^2+u(4)^2)*u(4)',num2str(g),']'],'t','u'); %odeset('abstol',1e-12,'reltol',1e-12); [t,u]=ode45(f,[0 4],[0 h0 v0*cos(alpha) v0*sin(alpha)]); %tim thoi diem vat tiep dat sp=spline(t,u(:,2)); fnplt(sp,[0 4],'r');grid on; [ty0 y0]=ginput(1); [tn yn]=fsolve(@(t)ppval(sp,t),ty0,optimset('display','off')); [t,u]=ode45(f,[0 tn],[0 h0 v0*cos(alpha) v0*sin(alpha)]); plot(u(:,1),u(:,2),'r');grid on;title('do thi quy dao');xlabel('x');ylabel('y'); 10 BÀI 17: CON LẮC KÉP function baitoan17 close all;clear;clc; syms l1 l2 m1 m2 g phi1 phi2 Dphi1 Dphi2 D2phi1 D2phi2 %phuong trinh lagrange x1=l1*sin(phi1);y1=l1*cos(phi1); T1=1/2*m1*l1^2*Dphi1^2; U1=-m1*g*y1; x2=x1+l2*sin(phi2);y2=y1+l2*cos(phi2); Dx2=diff(x2,phi1)*Dphi1+diff(x2,phi2)*Dphi2; Dy2=diff(y2,phi1)*Dphi1+diff(y2,phi2)*Dphi2; T2=1/2*m2*(Dx2^2+Dy2^2);U2=-m2*g*y2; L=(T1+T2-U1-U2); %giai phuong trinh lagrange d/dt(dL/dq.)-dL/dq=0 % bac tu la: q=[phi1 phi2] dLq1=diff(L,Dphi1); dLq2=diff(L,Dphi2); pt1=diff(dLq1,phi1)*Dphi1+diff(dLq1,phi2)*Dphi2+diff(dLq1,Dphi1)*D2 phi1+diff(dLq1,Dphi2)*D2phi2-diff(L,phi1); pt2=diff(dLq2,phi1)*Dphi1+diff(dLq2,phi2)*Dphi2+diff(dLq2,Dphi1)*D2 phi1+diff(dLq2,Dphi2)*D2phi2-diff(L,phi2); sol=solve(pt1,pt2,D2phi1,D2phi2); D2phi1=sol.D2phi1; D2phi2=sol.D2phi2; A={phi1,Dphi1,phi2,Dphi2}; ts={g,m1,m2,l1,l2};g=9.8;m1=2;m2=1;l1=1;l2=2; B={'u(1)','u(2)','u(3)','u(4)'};gt={9.8,2,1,1,2}; du2=subs(D2phi1,A,B);du2=char(subs(du2,ts,gt)); du4=subs(D2phi2,A,B);du4=char(subs(du4,ts,gt)); fu=inline(['[u(2);',du2,';u(4);',du4,']'],'t','u'); opt=odeset('reltol',1e-6,'abstol',1e-9); [t,u]=ode45(fu,[0 10],[pi/3 0 0],opt); phi1=u(:,1); Dphi1=u(:,2); phi2=u(:,3); Dphi2=u(:,4); T=subs(T1+T2,ts,gt); 30 T=subs(T,{'phi1','phi2','Dphi1','Dphi2'},{phi1,phi2,Dphi1,Dphi2}); U=subs(U1+U2,ts,gt); U=subs(U,{'phi1','phi2'},{phi1,phi2}); E=T+U; subplot(3,1,1); plot(t,phi1,t,phi2,'r');legend('phi1(t)','phi2(t)'); grid on; title('do thi toa phu thuoc thoi gian'); subplot(3,1,2); plot(t,Dphi1,t,Dphi2,'r'); legend('Dphi1(t)','Dphi2(t)');grid on; title('do thi van toc phu thuoc thoi gian'); subplot(3,1,3); plot(t,T,t,U,'r',t,E,'g');legend('dong nang','the nang','tong nang luong');grid on; title('do thi dong nang,the nang,nang luong phu thuoc thoi gian'); % hinh dong x01=l1*sin(pi/3); y01=l1*cos(pi/3); x02=x01+l2*sin(0);y02=y01+l2*cos(0); x0=[0 x01 x02]; y0=[0 y01 y02]; figure(2); h=plot(x0,y0,'.r-','markersize',30); axis([-2 -2 0]*(l1+l2)/2);hold on; k=1;n=0; u0=[pi/3 0 0]; while k [t,u]=ode45(fu,[0 1],u0); phi1=u(end,1);phi2=u(end,3); X1=l1*sin(phi1(k));Y1=-l1*cos(phi1(k)); X2=X1+l2*sin(phi2(k));Y2=Y1-l2*cos(phi2(k)); X=[0;X1;X2];Y=[0;Y1;Y2]; set(h,'xdata',X,'ydata',Y);pause(0.01); u0=u(end,:); n=n+1; if n==50;k=0;end; end 31 BÀI 18: PHÂN HỦY HẠT NHÂN – PP MONTE CARLO Kr Br Se function baitoan18 clear;close all;clc; N0=1000;T12Kr=14.8;T12Br=16.1; lmKr=log(2)/T12Kr;lmBr=log(2)/T12Br; tmax=200; Nthu=1000; %thoi gian thu va so lan thu ti=1:tmax; nKr=zeros(1,tmax); nBr=zeros(1,tmax); nSe=zeros(1,tmax); for k=1:Nthu NKr=ones(1,N0); NBr=zeros(1,N0); NSe=zeros(1,N0); for t=1:tmax r1=rand(size(NKr)); r2=rand(size(NBr)); NSe=NSe|(NBr&(r2lmBr); %so hat Br chua bi phan huy NBr=NBr|NKrph; %so hat Br bi phan huy Se nKr(t)=nKr(t)+sum(NKr); nBr(t)=nBr(t)+sum(NBr); nSe(t)=nSe(t)+sum(NSe); end end %so hat tai cac thoi diem t tinh theo phuong phap monte - carlo ti=[0 ti]; niKr=nKr/Nthu; niKr=[N0 niKr]; niBr=nBr/Nthu; niBr=[0 niBr]; niSe=nSe/Nthu; niSe=[0 niSe]; %so hat tai cac thoi diem t tinh theo phuong phap giai tich niKrgt=N0.*exp(-lmKr.*ti); niBrgt=N0.*lmKr./(lmKr-lmBr).*(exp(-lmBr.*ti)-exp(-lmKr.*ti)); niSegt=-N0/(lmKr-lmBr).*(lmBr-lmKr+lmKr.*exp(-lmBr.*ti)-lmBr.*exp(lmKr.*ti)); 32 plot(ti,niKr,'r',ti,niKrgt,'b',ti,niBr,'g',ti,niBrgt,'k',ti,niSe,'m ',ti,niSegt,'y'); legend('nKr_{mo phong}','nKr_{giai tich}','nBr_{mo phong}','nBr_{giai tich}','nSe_{mo phong}','nSe_{giai tich}'); % So hat Kr bi phan huy mot don vi thoi gian tuan theo phan bo poisson: Nthu=10000; nn=zeros(1,Nthu); for k=1:Nthu N=ones(1,N0); r=rand(size(N)); %N=N&(r>pKr); %nn(k)=N0-sum(N); N=N&(rtinh tan so cua mau Pi=np/Nthu; % for k=1:length(n) poisson=m.^n./factorial(n).*exp(-m); % end; figure(2) stem(n,Pi);hold on; plot(n,poisson,'.r-');hold off; title(['phan bo poisson voi =',num2str(m)]); BÀI 19: KHÚC XẠ ÁNH SÁNG function baitoan19 clc;clear all;close all; global N ntrial v d N=10;ntrial=2000;x=linspace(0,5,N+1); n1=1; n3=1; v1=1/n1; vv1=v1*ones(size(x((x0))));%Ma tran chiet suat moi truong v3=1/n3; vv3=v3*ones(size(x(x>3.5))); %Ma tran chiet suat moi truong while 33 k=menu('chon','n2=1.25','n2=1+(x-1.5)/4','n2=1.5-(x1.5)/4','thoat'); switch k case n2=1.25; v2=1./n2; vv2=v2*ones(size(x((x>1.5)&(x1.5)&(x=1.5)&(xt01 break end end pty=spline(al,yy1-yy2); al=fsolve(@(al)ppval(pty,al),0.8,optimset('display','off')); fprintf(['khi ko co ma sat, hai vat se va cham voi goc alpha= ',num2str(al*180/pi),' \n']); %thoi gian va vi tri va cham [t2,u2]=ode45(fu2,[0 5],[0;v0*cos(al);0;v0*sin(al)]); x2=spline(t2,u2(:,1)-10); y2=spline(t2,u2(:,3)); t02=fsolve(@(t2)ppval(x2,t2),1,optimset('display','off')); fprintf(['do cao va cham la: ',num2str(ppval(y2,t02)),' m \n']); fprintf(['thoi diem va cham la: ',num2str(t02),' s \n']); % khong co ma sat,hai vat se cham goc nem alpha = 45 % cao va cham la: 7.55 m % thoi diem va cham la: 0.70711 s % ko co ma sat, hai vat se va cham voi goc alpha= 44.8792 % cao va cham la: 7.4066 m % thoi diem va cham la: 0.72908 s BÀI 23: MẠCH DAO ĐỘNG RLC function baitoan23 close all;clear;clc; %cau a: R*q'(t)+q(t)/C=V(t),voi V(t)=V0*cos(w*t) pt1='R*Dq+q/C=V0*cos(w*t)'; q1=dsolve(pt1,'q(0)=q0'); q11=subs(q1,{'q0','V0','R','w'},{1,1,1,6}); q12=subs(q1,{'q0','V0','R','w','C'},{1,1,1,6,0.02}); figure(1); ezplot(q12,[0 6]);grid on; title('do thi ham q(t)'); xlabel('t');ylabel('q'); figure(2); f1=inline(char(q11),'t','C'); ezsurf(f1,[0 0.02 0.25]); title('do thi ham q(t,C)'); 41 xlabel('t');ylabel('C');zlabel('q'); %cau b: L*q''(t)+R*q'(t)=V(t).Voi V(t)=V0*cos(w*t) pt2='L*D2q+R*Dq=V0*cos(w*t)'; q2=dsolve(pt2,'q(0)=q0,Dq(0)=i0','t'); q21=subs(q2,{'q0','V0','R','w','i0','L'},{0,1,0.1,1,0.1,2}); figure(3); ezplot(q21,[0 20]);grid on; title('do thi q(t)'); xlabel('t');ylabel('q'); figure(4); i2=diff(q21); ezplot(i2,[0 20]);grid on; title('do thi q''(t)'); xlabel('t');ylabel('q'''); %cau c: L*q''(t)+R*q'(t)+q(t)/C=V(t) pt3='L*D2q+R*Dq+q/C=0'; q3=dsolve(pt3,'q(0)=q0,Dq(0)=i0','t'); q31=subs(q3,{'q0','R','i0','L','C'},{1,1,0,4,1}); q32=subs(q3,{'q0','R','i0','C'},{1,1,0,1}); figure(5); ezplot(q31,[0 30]);grid on; title('do thi q(t)'); xlabel('t');ylabel('q'); figure(6); i3=diff(q31); ezplot(i3,[0 30]);grid on; title('do thi q''(t)'); xlabel('t');ylabel('q'''); figure(7); f3=inline(char(q32),'t','L'); ezsurf(f3,[0 30 4]); title('di thi q(t,L)'); xlabel('t');ylabel('L');zlabel('q'); 42 BÀI 24: CON LẮC ĐƠN TREO BẰNG LÒ XO function baitoan24 close all;clear;clc; syms m k L0 g r phi Dphi Dr D2phi D2r %phuong trinh Lagrange T=m/2*(Dr^2+r^2*Dphi^2); U=1/2*k*(L0-r)^2+m*g*(L0-r*cos(phi)); L=T-U; %phuong trinh lagrange: d/dt(dL/dq.)-dL/dq=0 ;2 bac tu la: q=[r, phi] dLr=diff(L,Dr); pt1=diff(dLr,r)*Dr+diff(dLr,Dr)*D2r+diff(dLr,phi)*Dphi+diff(dLr,Dph i)*D2phi-diff(L,r); dLphi=diff(L,Dphi); pt2=diff(dLphi,r)*Dr+diff(dLphi,Dr)*D2r+diff(dLphi,phi)*Dphi+diff(d Lphi,Dphi)*D2phi-diff(L,phi); sol=solve(pt1,pt2,D2r,D2phi); D2r=simple(sol.D2r); disp('r''''(t)=');pretty(D2r); D2phi=simple(sol.D2phi); disp('phi''''(t)=');pretty(D2phi); %tinh dong nang, the nang, nang luong toan phan A={r,Dr,phi,Dphi};ts={L0,k,g,m};L0=4;k=4;g=9.8;m=1; B={'u(1)','u(2)','u(3)','u(4)'};gt={4,4,9.8,1}; du2=subs(D2r,A,B);du2=char(subs(du2,ts,gt)); du4=subs(D2phi,A,B);du4=char(subs(du4,ts,gt)); fu=inline(['[u(2);',du2,';u(4);',du4,']'],'t','u'); opt=odeset('reltol',1e-6,'abstol',1e-9); [t,u]=ode45(fu,[0 10],[4 pi/2 0],opt); r=u(:,1); Dr=u(:,2); phi=u(:,3); Dphi=u(:,4); T=m/2*(Dr.^2+r.^2.*Dphi.^2); U=1/2.*k.*(L0-r).^2+m.*g.*(L0-r.*cos(phi)); E=T+U; plot(t,T,t,U,'r',t,E,'g');grid on; legend('T(t)','U(t)','E(t)'); 43 %ve quy dao x=r.*sin(phi);y=(-1)*r.*cos(phi); figure(2); plot(x,y);hold on;grid on; h=plot([0 x(1)],[0 y(1)],':g',x(1),y(1),'.r','markersize',50); axis([-6 -12 0]); for k=2:length(y) set(h(1),'xdata',[0 x(k)],'ydata',[0 y(k)]); set(h(2),'xdata',x(k),'ydata',y(k)); pause(0.02); end % r''(t)= % % L0 k - k r % Dphi r + g cos(phi) + -% m % phi''(t)= % % g sin(phi) + Dphi Dr % - -% r BÀI 25: ĐIỆN TÍCH CHUYỂN ĐỘNG TRONG ĐIỆN TỪ TRƯỜNG function baitoan25 clc; syms r x y z Dx Dy Dz E B q m t Bv=[0 -B 0]; Ev=[0 E]; v=[Dx Dy Dz]; F=q*Ev+q*cross(v,Bv); pt=['m*D2x=', char(F(1)), ',', 'm*D2y=', char(F(2)), ',', 'm*D2z=', char(F(3))]; dk='x(0)=0,y(0)=0,z(0)=0,Dx(0)=0,Dy(0)=0,Dz(0)=0'; sol=dsolve(pt,dk,'t'); xx=sol.x; yy=sol.y; zz=sol.z; t1=solve(zz-z,t); %rut t theo z de thay vao x: z=f(z) => t=t(z) ptx=subs(xx,t,t1); fprintf('phuong trinh quy dao: \n x = '); pretty(ptx); 44 [...]...figure(2); subplot(2,2,1);plot(t,u(:,1));title('do thi x theo thoi gian');grid on;xlabel('t');ylabel('x'); subplot(2,2,2);plot(t,u(:,2));title('do thi y theo thoi gian');grid on;xlabel('t');ylabel('y'); subplot(2,2,3);plot(t,u(:,3));title('do thi vx theo thoi gian');grid on;xlabel('t');ylabel('vx'); subplot(2,2,4);plot(t,u(:,4));title('do thi vy theo thoi gian');grid on;xlabel('t');ylabel('vy');... plot(t,phi1,t,phi2,'r');legend('phi1(t)','phi2(t)'); grid on; title('do thi toa do phu thuoc thoi gian'); subplot(3,1,2); plot(t,Dphi1,t,Dphi2,'r'); legend('Dphi1(t)','Dphi2(t)');grid on; title('do thi van toc phu thuoc thoi gian'); subplot(3,1,3); plot(t,T,t,U,'r',t,E,'g');legend('dong nang','the nang','tong nang luong');grid on; title('do thi dong nang,the nang,nang luong phu thuoc thoi gian'); % hinh dong... [ti2,h2]=ode45(eqs2,[t1,120],[h1(end,1) h1(end,2)]); sp=spline(ti2,h2(:,1)); %thoi diem cham dat và do cao cuc dai 14 tg=fsolve(@(ti2)ppval(ti2,sp),100,optimset('display','off')); fprintf(['Thoi diem cham dat: ',num2str(tg),'s\n']); [tmax,hmax]=fminsearch(@(ti2)-ppval(ti2,sp),32); fprintf(['Do cao cuc dai: ',num2str(-hmax),'m\n']); % Do thi: fnplt(sp,[t1,tg],'b');hold on;grid on; plot(ti1(end),h1(end,1),'ok',ti1,h1(:,1),'r');grid... %Hien thi so lan lap end hold off; end % -function y=fermat(x,y,h) global N v d k=fix((N-1)*rand)+2; ym=y(k)+(2*rand-1)*d; t1=sqrt((x(k)-x(k-1))^2+(y(k)-y(k-1))^2)/v(k-1); t1=t1+sqrt((x(k+1)-x(k))^2+(y(k+1)-y(k))^2)/v(k); t2=sqrt((x(k)-x(k-1))^2+(ym-y(k-1))^2)/v(k-1); t2=t2+sqrt((x(k+1)-x(k))^2+(y(k+1)-ym)^2)/v(k); if t2 ... mn13=double(subs(NPbt,'t',sym(tn13))); fprintf(['Pb co khoi luong bang 1/3Rn tai t= ',num2str(tn13),' mPb= ',num2str(mn13),' ']); NPb23Rn=inline(vectorize(NPbt-2/3*NRnt),'t'); NPb23Rni=double(subs(NPbt,'t',sym(ti))-2/3*subs(NRnt,'t',sym(ti)));... %Thoi diem mPb=1/3mRn va mPb=2/3mRn figure(2); NPb13Rn=inline(vectorize(NPbt-1/3*NRnt),'t'); NPb13Rni=double(subs(NPbt,'t',sym(ti))-1/3*subs(NRnt,'t',sym(ti))); plot(ti,NPb13Rni,'r');grid on;hold... vv3=v3*ones(size(x(x>3.5))); %Ma tran chiet suat moi truong while 33 k=menu('chon','n2=1 .25' ,'n2=1+(x-1.5)/4','n2=1.5-(x1.5)/4','thoat'); switch k case n2=1 .25; v2=1./n2; vv2=v2*ones(size(x((x>1.5)&(x1.5)&(x