Автор работы: Пользователь скрыл имя, 14 Января 2014 в 16:18, курсовая работа
Цель работы: освоение приемов моделирование динамических систем с помощью ‘’MATLAB’’
Определение показателей качества динамических систем.
Введение……………………………………………………………………………...3
1. Задание……………………………………………..……..…………….………..4
2. Цель……………………………………………………….………………………5
3. Основная часть…………………………………………….……………………..6
4. Эксплуатация программного продукта……………………………………….16
Заключение………………………………………………………………………….17
Список использованных источников……………………………...………………18
Приложение А Листинг программы………………………………………………19
Panel3: TPanel;
Label28: TLabel;
Label29: TLabel;
Label32: TLabel;
StringGrid11: TStringGrid;
Panel4: TPanel;
Label7: TLabel;
Label14: TLabel;
Label15: TLabel;
StringGrid7: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
k,i,j:integer;
sum,n,c,t:integer;
S,OC,cor,Am,IC:real;
implementation
{$R *.dfm}
function koren(step,chislo:real):real;
begin
koren:=exp((1/step)*ln(chislo)
end;
procedure max(StringGrid: TStringGrid;Edit: TEdit);
begin
s:=0;
with StringGrid do
for i:=1 to n do
begin
s:=s+(strtofloat(Cells[n+2,i])
end;
with edit do Text:=floattostr(roundto(s,-3)
end;
procedure uc(Edit:TEdit);
begin
with edit do Text:=floattostr((Am-n)/(n-1))
end;
procedure OtCo(Edit:TEdit);
begin
case n of
3: OC:=0.58;
4: OC:=0.9;
5: OC:=1.12;
6: OC:=1.24;
7: OC:=1.32;
8: OC:=1.41;
9: OC:=1.45;
10: OC:=1.49;
end;
with edit do Text:=floattostr(roundto(IC/
end;
procedure Schet(StringGrid: TStringGrid);
begin
with StringGrid do
begin
for j:=1 to n do
begin
s:=1;
t:=0;
for i:=1 to n do
begin
t:=t+1;
s:=s*strtofloat(Cells[i,j]);
end;
Cells[t+1,j]:=floattostr(
end;
for i:=1 to n+1 do
begin
t:=0;
s:=0;
for j:=1 to n do
begin
t:=t+1;
s:=s+strtofloat(Cells[i,j]);
end;
Cells[i,t+1]:=floattostr(
end;
s:=0;
with StringGrid do
for i:=1 to n do
begin
Cells[n+2,i]:=floattostr(
end; end; end;
procedure SaveStringGrid(StringGrid: TStringGrid; const FileName: TFileName);
var
f: TextFile;
begin
AssignFile(f, FileName);
Rewrite(f);
with StringGrid do
begin
// Write number of Columns/Rows
Writeln(f, ColCount);
Writeln(f, RowCount);
// loop through cells
for i := 0 to ColCount - 1 do
for j := 0 to RowCount - 1 do
Writeln(F, Cells[i, j]);
end;
CloseFile(F); end;
procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName);
var
f: TextFile;
iTmp: Integer;
strTemp: String;
begin
AssignFile(f, FileName);
Reset(f);
with StringGrid do
begin
// Get number of columns
Readln(f, iTmp);
ColCount := iTmp;
// Get number of rows
Readln(f, iTmp);
RowCount := iTmp;
// loop through cells & fill in values
for i := 0 to ColCount - 1 do
for j := 0 to RowCount - 1 do
begin
Readln(f, strTemp);
Cells[i, j] := strTemp;
end;
end;
CloseFile(f); end;
procedure Sbor;
var
a,b:integer;
z,s:real;
begin
a:=5;
b:=3;
Form1.Panel3.Visible:=true;
LoadStringGrid(form1.
For i:=1 to a do
begin
for j:=0 to b+2 do
begin
if j=0
then form1.StringGrid11.Cells[i,j]:
form1.StringGrid11.Cells[i,1]:
end; end;
for i:=2 to b+1 do
begin
form1.StringGrid11.Cells[1,i]:
form1.StringGrid11.Cells[2,i]:
form1.StringGrid11.Cells[3,i]:
form1.StringGrid11.Cells[4,i]:
form1.StringGrid11.Cells[5,i]:
//form1.StringGrid11.Cells[6,
end;
for j:=2 to b+1 do
begin
z:=0;
for i:=1 to a do
begin
z:=z+(strtofloat(form1.
form1.StringGrid11.Cells[a+1,
if z>s then
begin
s:=z;
form1.Label28.Caption:='Автомо
end; end; end; end;
procedure TForm1.Button1Click(Sender: TObject);
begin
If messageBox(Handle,'Сохранить изменения ?','Выход',
mb_YesNoCancel or mb_iconquestion)=mrYes then
SaveStringGrid(StringGrid1, 'temp.txt');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Edit1.Text:='';
If messageBox(Handle,'Загрузить из файла ?','Выход',
mb_YesNoCancel or mb_iconquestion)=mrYes then
begin
form1.Button2.Enabled:=false;
form1.Button1.Enabled:=false;
LoadStringGrid(StringGrid1, 'temp.txt');
form1.Edit1.Text:=inttostr(
end;
form1.StringGrid1.Options:=[
end;
procedure preob(StringGrid: TStringGrid);
var
s:string;
A:integer;
begin
with StringGrid do
begin
for i:=1 to n do
begin
for j:=1 to n do
begin
s:=Cells[i,j];
if length(s)>2 then
begin
for a:=1 to length(s) do
begin
if s[a]='/' then
begin
Cells[i,j]:=floattostr(
end;
end;
end;
end;
end;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
preob(StringGrid1);
Schet(StringGrid1);
Amax (StringGrid1,edit3);
Am:=strtofloat(form1.Edit3.
uc(edit4);
Ic:=strtofloat(form1.Edit4.
OtCo(edit5);
LoadStringGrid(StringGrid2, '10.txt');
LoadStringGrid(StringGrid3, '10.txt');
LoadStringGrid(StringGrid4, '10.txt');
LoadStringGrid(StringGrid5, '10.txt');
LoadStringGrid(StringGrid6, '10.txt');
//form1.Panel1.Visible:=false;
Form1.Panel2.Visible:=true;
form1.StringGrid2.Cells[0,0]:=
form1.StringGrid3.Cells[0,0]:=
form1.StringGrid4.Cells[0,0]:=
form1.StringGrid5.Cells[0,0]:=
form1.StringGrid6.Cells[0,0]:=
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
form1.Edit2.Text:='';
form1.StringGrid2.Options:=[
form1.StringGrid3.Options:=[
form1.StringGrid4.Options:=[
form1.StringGrid5.Options:=[
form1.StringGrid6.Options:=[
form1.StringGrid11.Options:=[
If messageBox(Handle,'Загрузить из файла ?','Выход',
mb_YesNoCancel or mb_iconquestion)=mrYes then
begin
form1.Button5.Enabled:=false;
form1.Button4.Enabled:=false;
LoadStringGrid(StringGrid2, '2.txt');
LoadStringGrid(StringGrid3, '3.txt');
LoadStringGrid(StringGrid4, '4.txt');
LoadStringGrid(StringGrid5, '5.txt');
LoadStringGrid(StringGrid6, '6.txt');
form1.Edit2.Text:=inttostr(
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
If messageBox(Handle,'Сохранить изменения ?','Выход',
mb_YesNoCancel or mb_iconquestion)=mrYes then
Begin
SaveStringGrid(StringGrid2, '2.txt');
SaveStringGrid(StringGrid3, '3.txt');
SaveStringGrid(StringGrid4, '4.txt');
SaveStringGrid(StringGrid5, '5.txt');
SaveStringGrid(StringGrid6, '6.txt');
end; end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if edit1.Text<>'' then
begin
if (strtoint(form1.Edit1.Text)<
begin
n:=strtoint(form1.Edit1.text);
form1.StringGrid1.ColCount:=n+
form1.StringGrid1.RowCount:=n+
end; end; end;
procedure Izmeneniematric(StringGrid: TStringGrid);
begin
with StringGrid do
begin
n:=strtoint(form1.Edit2.text);
ColCount:=n+3;
RowCount:=n+2;
end; end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
if edit2.Text<>'' then
begin
if (strtoint(form1.Edit1.Text)<
begin
izmeneniematric(stringgrid2);
izmeneniematric(stringgrid3);
izmeneniematric(stringgrid4);
izmeneniematric(stringgrid5);
izmeneniematric(stringgrid6);
end; end; end;
procedure TForm1.Button6Click(Sender: TObject);
begin
preob(StringGrid2);
preob(StringGrid3);
preob(StringGrid4);
preob(StringGrid5);
preob(StringGrid6);
Schet(StringGrid2);
Schet(StringGrid3);
Schet(StringGrid4);
Schet(StringGrid5);
Schet(StringGrid6);
max (StringGrid2,edit6);
max (StringGrid3,edit10);
max (StringGrid4,edit7);
max (StringGrid5,edit11);
max (StringGrid6,edit8);
n:=form1.StringGrid2.RowCount-
Am:=strtofloat(form1.Edit6.
uc(edit14);
Am:=strtofloat(form1.Edit10.
uc(edit23);
Am:=strtofloat(form1.Edit7.
uc(edit17);
Am:=strtofloat(form1.Edit11.
uc(edit25);
Am:=strtofloat(form1.Edit8.
uc(edit19);
IC:=strtofloat(form1.Edit14.
OtCo(edit15);
IC:=strtofloat(form1.Edit23.
OtCo(edit22);
IC:=strtofloat(form1.Edit17.
OtCo(edit16);
IC:=strtofloat(form1.Edit25.
OtCo(edit24);
IC:=strtofloat(form1.Edit19.
OtCo(edit18);
Sbor;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Not (Key in ['0'..'9', #8])then Key:=#0;
end;
procedure TForm1.StringGrid1KeyPress(
begin
for i:=1 to form1.StringGrid1.ColCount do
for j:=1 to form1.StringGrid1.RowCount do
if Not (Key in ['0'..'9','/', #8])then Key:=#0;
end;
end.
Информация о работе Моделирование типовой динамической системы в среде “ MATLAB”