Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Курсачёк.docx
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
353.31 Кб
Скачать

Заключение

В процессе выполнения курсовой работы по информатике были решены следующие задачи:

  1. Разработана математическая модель движителя подводной лодки;

  2. Представили математическую модель движителя в форме Коши;

  3. Выписали систему дифференциальных уравнений в форме пространства состояний;

  4. Сформировали структурную схему движителя в Simulink

  5. Создали структурную схему ориентации в пространстве модели подлодки;

  6. В среде VR-Builder создали виртуальную модель подводной лодки;

  7. Выполнили подключение модуля VR Sink к Simulink модели подводной лодки;

  8. Создали S-функцию визуализатора параметров движителя;

  9. Сформировали структурную схему системы моделирования плавания виртуальной модели подлодки;

  10. Провели численные эксперименты моделирования подлодки.

Список использованой литературы

  1. Matlab. Режим доступа: http://www.mathworks.com/products/matlab/

  2. Лабораторные работы: http://matlab.exponenta.ru/matlab/default.php

  3. Основы информатики.  Савельев А.Я. Изд-во МГТУ им Н.Э. Баумана, 2001. — 328 с.

Приложение 1

Код для S-function

function [sys, x0, str, ts] = mysfun(t, x, u, flag)

case 0

[sys, x0, str, ts] = mdlInitializeSizes;

case 2

sys=mdlUpdate(t, x, u);

case 3

sys=mdlOutputs(t,x,u);

case 9

sys=mdlTerminate(t,x,u);

otherwise

error(['Unhandled flag = ',num2str(flag)]);

end

function [sys, x0, str, ts] = mdlInitializeSizes

sizes = simsizes;

sizes.NumInputs = 4;

sizes.NumSampleTimes = 1;

sys = simsizes(sizes);

x0 = [];

str = [];

ts = [-1 0];

Fig=figure('Position',[644 -11 551 685],...

'Color', 'k',...

'MenuBar', 'none',...

'Name', 'GUI_Simulink',...

'NumberTitle', 'off');

InitControl = 1;

uicontrol('Style', 'slider',...

'Position',[50 485 451 18],...

'Min', 0, 'Max', 220, 'Value', InitControl,...

'Callback', @sldCallback);

set_param([gcs '/Control'],'Value',num2str(InitControl));

axes('Tag', 'ax1',...

'Units', 'pixels',...

'Position',[50 334 451 101],...

'NextPlot','add',...

'Xlim', [0 50],...

'Ylim', [-500 1500],...

'Color','k',...

'Xcolor', 'g',...

'YColor', 'g',...

'Box', 'on',...

'XGrid', 'on',...

'YGrid', 'on');

axes('Tag', 'ax2',...

'Units', 'pixels',...

'Position',[50 534 451 101],...

'NextPlot','add',...

'Xlim', [0 50],...

'Ylim', [-5 250],...

'Color','k',...

'Xcolor', 'g',...

'YColor', 'g',...

'Box', 'on',...

'XGrid', 'on',...

'YGrid', 'on');

axes('Tag', 'ax3',...

'Units', 'pixels',...

'Position',[50 184 451 101],...

'NextPlot','add',...

'Xlim', [0 50],...

'Ylim', [-5 30],...

'Color','k',...

'Xcolor', 'g',...

'YColor', 'g',...

'Box', 'on',...

'XGrid', 'on',...

'YGrid', 'on');

axes('Tag', 'ax4',...

'Units', 'pixels',...

'Position',[50 34 451 101],...

'NextPlot','add',...

'Xlim', [0 50],...

'Ylim', [0 250],...

'Color','k',...

'Xcolor', 'g',...

'YColor', 'g',...

'Box', 'on',...

'XGrid', 'on',...

'YGrid', 'on');

uicontrol('Style', 'text',...

'String', 'Signal',...

'Position', [200 445 151 26],...

'FontSize', 10,...

'FontWeight', 'bold',...

'BackgroundColor', 'k',...

'ForegroundColor', 'm')

uicontrol('Style', 'text',...

'String', 'Control',...

'Position', [200 644 151 23],...

'FontSize', 10,...

'FontWeight', 'bold',...

'BackgroundColor', 'k',...

'ForegroundColor', 'y')

uicontrol('Style', 'text',...

'String', 'angular velocity',...

'Position', [199 285 151 22],...

'FontSize', 10,...

'FontWeight', 'bold',...

'BackgroundColor', 'k',...

'ForegroundColor', 'r')

uicontrol('Style', 'text',...

'String', 'angle of rotation',...

'Position', [199 135 151 22],...

'FontSize', 10,...

'FontWeight', 'bold',...

'BackgroundColor', 'k',...

'ForegroundColor', 'b')

set_param(gcbh, 'UserData', Fig);

function sys=mdlUpdate(t, x, u)

Fig = get_param(gcbh,'UserData');

Handles = guihandles(Fig);

PassedSampleNum = int32(t*10);

if mod(PassedSampleNum, 500) == 0

set(Handles.ax1, 'XLim', [t t+50])

set(Handles.ax2, 'XLim', [t t+50])

set(Handles.ax3, 'XLim', [t t+50])

set(Handles.ax4, 'XLim', [t t+50])

end

axes(Handles.ax1)

LastPoint = get(Handles.ax1, 'UserData');

if ~isempty(LastPoint)

plot([LastPoint(1) t],[LastPoint(2) u(2)],...

'Color', 'm', 'LineWidth', 2)

set(Handles.ax1, 'UserData', [t, u(2)])

else

set(Handles.ax1, 'UserData', [t, u(1)*u(2)])

plot(t, u(1)*u(2), 'Color', 'm', 'LineWidth', 2 )

end

axes(Handles.ax2)

LastPoint = get(Handles.ax2, 'UserData');

if ~isempty(LastPoint)

plot([LastPoint(1) t],[LastPoint(2) u(1)],...

'Color', 'y', 'LineWidth', 2)

set(Handles.ax2, 'UserData', [t, u(1)])

else

set(Handles.ax2, 'UserData', [t, u(1)])

plot(t, u(1), 'Color', 'y', 'LineWidth', 2 )

end

axes(Handles.ax3)

LastPoint = get(Handles.ax3, 'UserData');

if ~isempty(LastPoint)

plot([LastPoint(1) t],[LastPoint(2) u(3)],...

'Color', 'r', 'LineWidth', 2)

set(Handles.ax3, 'UserData', [t, u(3)])

else

set(Handles.ax3, 'UserData', [t, u(1)])

plot(t, u(3), 'Color', 'r', 'LineWidth', 1 )

end

axes(Handles.ax4)

LastPoint = get(Handles.ax4, 'UserData');

if ~isempty(LastPoint)

plot([LastPoint(1) t],[LastPoint(2) u(4)],...

'Color', 'b', 'LineWidth', 2)

set(Handles.ax4, 'UserData', [t, u(4)])

else

set(Handles.ax4, 'UserData', [t, u(1)])

plot(t, u(4), 'Color', 'b', 'LineWidth', 1 )

end

sys = [];

function sys=mdlOutputs(t,x,u)

sys=[];

function sys=mdlTerminate(t,x,u)

button = questdlg('Delete the GUI_Simulink window?','GUI_Simulink',...

'No','Yes','No');

if isequal(button, 'Yes')

Fig = get_param(gcbh,'UserData');

delete(Fig)

end

sys = [];

function sldCallback(src,evt)

s = get(src, 'Value');

set_param([gcs '/Control'], 'Value', num2str(s));

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]