Математические и программные модели движения кораблей
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
in{:});
% End initialization code - DO NOT EDIT
% --- Executes just before Kurs_gui is made visible.Kurs_gui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Kurs_gui (see VARARGIN)
% Choose default command line output for Kurs_gui.output = hObject;
% Update handles structure(hObject, handles);
% UIWAIT makes Kurs_gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);(handles.W,'String',0);(handles.N,'String',0);(handles.V1,'String',0);(handles.V1max,'String',0);(handles.V2max,'String',0);
% --- Outputs from this function are returned to the command line.varargout = Kurs_gui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure{1} = handles.output;
% --- Executes on button press in ship1.ship1_Callback(hObject, eventdata, handles)
% hObject handle to ship1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)get(hObject,'Value')==1(handles.text1,'Visible','On');(handles.text2,'Visible','On');(handles.text3,'Visible','On');(handles.ship2,'Value', 0);(handles.ship3,'Value', 0);(handles.W,'Visible','On');(handles.N,'Visible','On');(handles.V1,'Visible','On');(handles.text6,'Visible','Off');(handles.text7,'Visible','Off');(handles.V1max,'Visible','Off');(handles.V2max,'Visible','Off');(handles.W,'String',9030);(handles.N,'String',55000);(handles.V1,'String',29);(handles.text1,'Visible','Off');(handles.text2,'Visible','Off');(handles.text3,'Visible','Off');(handles.W,'Visible','Off');(handles.N,'Visible','Off');(handles.V1,'Visible','Off');
% Hint: get(hObject,'Value') returns toggle state of ship1
% --- Executes on button press in ship2.ship2_Callback(hObject, eventdata, handles)
% hObject handle to ship2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)get(hObject,'Value')==1(handles.text1,'Visible','On');(handles.text2,'Visible','On');(handles.text3,'Visible','On');(handles.ship1,'Value', 0);(handles.ship3,'Value', 0);(handles.W,'Visible','On');(handles.N,'Visible','On');(handles.V1,'Visible','On');(handles.text6,'Visible','Off');(handles.text7,'Visible','Off');(handles.V1max,'Visible','Off');(handles.V2max,'Visible','Off');(handles.W,'String',2.3);(handles.N,'String',150);(handles.V1,'String',29);(handles.text1,'Visible','Off');(handles.text2,'Visible','Off');(handles.text3,'Visible','Off');(handles.W,'Visible','Off');(handles.N,'Visible','Off');(handles.V1,'Visible','Off');
% Hint: get(hObject,'Value') returns toggle state of ship2
% --- Executes on button press in ship3.ship3_Callback(hObject, eventdata, handles)
% hObject handle to ship3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)get(hObject,'Value')==1(handles.text1,'Visible','On');(handles.text2,'Visible','On');(handles.text3,'Visible','On');(handles.text6,'Visible','On');(handles.text7,'Visible','On');(handles.ship1,'Value', 0);(handles.ship2,'Value', 0);(handles.W,'Visible','On');(handles.N,'Visible','On');(handles.V1,'Visible','On');(handles.V1max,'Visible','On');(handles.V2max,'Visible','On');(handles.W,'String',9.4);(handles.N,'String',400);(handles.V1,'String',11);(handles.V1max,'String',13);(handles.V2max,'String',32);(handles.text1,'Visible','Off');(handles.text2,'Visible','Off');(handles.text3,'Visible','Off');(handles.text6,'Visible','Off');(handles.text7,'Visible','Off');(handles.W,'Visible','Off');(handles.N,'Visible','Off');(handles.V1,'Visible','Off');(handles.V1max,'Visible','Off');(handles.V2max,'Visible','Off');
% Hint: get(hObject,'Value') returns toggle state of ship3
% --- Executes on button press in close.close_Callback(hObject, eventdata, handles)
% hObject handle to close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in change.change_Callback(hObject, eventdata, handles)
% hObject handle to change (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)get(hObject,'Value')==1(handles.W,'Style','edit');(handles.N,'Style','edit');(handles.V1,'Style','edit');(handles.V1max,'Style','edit');(handles.V2max,'Style','edit');
% --- Executes on button press in ok.ok_Callback(hObject, eventdata, handles)
% hObject handle to ok (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)(get(handles.ship1,'Value')==1 || get(handles.ship2,'Value')==1)get(handles.ship3,'Value')==1(handles.text15,'Visible','On');(handles.text16,'Visible','On');(handles.text17,'Visible','On');tab_Callback(hObject, eventdata, handles)
% hObject handle to tab (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)(get(handles.ship1,'Value')==1 || get(handles.ship2,'Value')==1)get(handles.ship3,'Value')==1=[]; j=1;get(handles.ship1,'Value')==1i=1:5:length(tt),(j,:)=[tt(i), XX(i), vv(i), pp(i)];=j+1;(get(handles.ship2,'Value')==1 || get(handles.ship3,'Value')==1)i=1:1:length(tt),(j,:)=[tt(i), XX(i), vv(i), pp(i)];=j+1;('%s',' Время Путь Скорость Тяга')(B)
Текст скрипта KursoviK.m
W_h = handles.W; % выбор объекта а1 из родительского объекта
W = str2double(get(W_h,'String')); % извлечение численного значения из объекта а1
N_h = handles.N;= str2double(get(N_h,'String'));_h = handles.V1;= str2double(get(V_h,'String'));
% W=9030; N=55000; V=29;
% 1 шаг приращения
dt=1;
% перевод в сист Си
W1=W*1000; N1=N*735.5; V1=V*0.51;
Fmax=N1/V1;get(handles.ship1,'Value')==1=0.1*Fmax;get(handles.ship2,'Value')==1=0.2*Fmax;
% 2=dt*(dFmax/Fmax)*100;
% 3
A=Fmax/(V1^2);
% Пройденное расстояние
xi=0; x_pre=0; P=0; t=0;
global tt; global XX; global vv; global pp;=[]; tt=[]; vv=[]; pp=[];
while P<100 % разгон + выход на макс значение силы тяги
X=xi+(xi-x_pre)+(P*Fmax*(dt^2)/100-A*(xi-x_pre)*abs(xi-x_pre))/W1;=(X-xi)/dt;=[vv,v];=[pp,P];_pre=xi; xi=X;=P+dP;=[tt,t];=[XX,X];=t+dt;
end;
while v<0.98*V1, % разгон на макс тяге до макс скорости
X=xi+(xi-x_pre)+(P*Fmax*(dt^2)/100-A*(xi-x_pre)*abs(xi-x_pre))/W1;=(X-xi)/dt;=[vv,v];=[pp,P];_pre=xi; xi=X;=[tt,t];=[XX,X];=t+dt;
end;
while P>-100, % торможение, выход на обратную силу тяги
X=xi+(xi-x_pre)+(P*Fmax*(dt^2)/100-A*(xi-x_pre)*abs(xi-x_pre))/W1;=(X-xi)/dt;=[vv,v];_pre=xi; xi=X;=[pp,P];=P-dP;=[tt,t];=[XX,X];=t+dt;
end;
while v>0.02, % торможение, до нуля
X=xi+(xi-x_pre)+(P*Fmax*(dt^2)/100-A*(xi-x_pre)*abs(xi-x_pre))/W1;=(X-xi)/dt;=[vv,v];=[pp,P];_pre=xi; xi=X;=[tt,t];=[XX,X];=t+dt;;get(handles.ok,'Value')==1(handles.XX_plot,'Visible','On');(handles.XX_plot);;(tt,XX), grid;(handles.vv_plot,'Visible','On');(handles.vv_plot);;(tt,vv), grid(handles.pp_plot,'Visible','On');(handles.pp_plot);;(tt,pp), grid
Текст скрипта KursoviKPK.m
% W=9.4; N=400; V_k=11; V_1max=13; V_2max=32;_h = handles.W; % выбор объекта а1 из родительского объекта
W = str2double(get(W_h,'String')); % извлечение численного значения из объекта а1
N_h = handles.N;= str2double(get(N_h,'String'));_h = handles.V1;_k = str2double(get(Vk_h,'String'));max_h = handles.V1max;_1max = str2double(get(V1max_h,'String'));max_h = handles.V2max;_2max= str2double(get(V2max_h,'String'));
% 1 шаг приращения
dt=1;
% перевод в сист Си
W1=W*1000; N1=N*735.5; Vk=V_k*0.51; V1max=V_1max*0.51; V2max=V_2max*0.51;=N1/V2max; dFmax=0.2*Fmax;
% 2=dt*(dFmax/Fmax)*100;
% 3=Fmax/(V1max^2); A2=Fmax/(V2max^2);
% Пройденное расстояние
xi=0; x_pre=0; P=0; t=0; v=0;
global tt; global XX; global vv; global pp;=[]; tt=[]; vv=[]; pp=[]; AA=[]; P<100 % разгон + выход на макс значение силы тяги
if(v=V1max)=A2;(Vk<=v & v<V1max)=A1-(v-Vk)*(A1-A2)/(V1max-Vk);=[AA,A];=xi+(xi-x_pre)+(P*Fmax*(dt^2)/100-A*(xi-x_pre)*abs(xi-x_pre))/W1;=(X-xi)/dt;=[vv,v];=[pp,P];_pre=xi; xi=X;=P+dP;=[tt,t];=[XX,X];=t+dt;
end;
while v<0.98*V2max, % разгон на макс тяге до макс скорости
if(v-