|
Tài trợ cho PIC Vietnam |
Matlab-Simulink & Labview & 20-Sim Các công cụ mô phỏng đa ngành... |
|
Ðiều Chỉnh | Xếp Bài |
03-06-2009, 06:08 PM | #1 |
Nhập môn đệ tử
Tham gia ngày: Jun 2009
Bài gửi: 3
: |
1 bai roan cn cac bro jai quyet jup
day la 1 bai toan thuoc ve chyen nhang cong trinh thuy loi bon em.Noi chung la em nho cac bro jup em cai vong lap While ay.ket qua thi dung roi nhung ma no ko chiu dung lai.
Nom na thi bai toan la the nay.Bai toan toi uu,Cac bac nhin thay cai ma tran K chua,Day,cu lap nhu the den thi nao cac phan tu o hang 1 cua K deu duong thi dung lai. Code:
function thu K=[1 -3 -5 0 0 0 0;0 1 0 1 0 0 4;0 0 1 0 1 0 6;0 3 2 0 0 1 18] disp('tim cot quay va bien thay the') m=3 n=2 while 1 K(1,:)>0 for i=2:n+1 min(K(1,:)); if K(1,i)==min(K(1,:)) disp('cot quay la') cotquay=i disp('bien thay the la') bienthaythex=i-1 end end if K(:,cotquay)<0 disp('phuong an nghiem ban dau khong nam tren bien') disp('chon lai buoc 0') end disp('tim hang quay va bien bi thay the') K4=K(:,cotquay) K5=K(:,m+n+2) teta=K5./K4 kq=[]; for i=2:m+1 if (teta(i,1)>0)&(teta(i,1)~=inf) kq = [kq, teta(i,:)]; end end teta1=kq tetamin=min(teta1) for i=2:m+1 if teta(i,1)==tetamin disp('hang quay la') hangquay=i disp('bien bi thay the la') bienbithaythex=i+1 end end K(hangquay,:) K(hangquay,cotquay) hesohangcobienmoi=K(hangquay,:)/K(hangquay,cotquay) if hangquay==m+1 i=1:hangquay-1 K(i,:)=K(i,:)-K(i,cotquay)*hesohangcobienmoi K(hangquay,:)=hesohangcobienmoi else for i=1:hangquay-1 K(i,:)=K(i,:)-K(i,cotquay)*hesohangcobienmoi K(hangquay,:)=hesohangcobienmoi end for i=hangquay+1:m+1 K(i,:)=K(i,:)-K(i,cotquay)*hesohangcobienmoi K(hangquay,:)=hesohangcobienmoi end end K if K(1,:)>0 break end end end thay đổi nội dung bởi: ngohaibac, 21-06-2009 lúc 12:20 PM. Lý do: thêm tag code |
|
|