Категории
Хирургия
Global hTxt1,hTxt2,hTxt3,hTxt4,hTxt5,hTxt6,hTxt7 просмотров - 321
%-----------------------------------------------
hFig1 = figure
hAxes = axes('Parent',hFig1,'Color', [ 1 1 1],'Units', ...
'points', 'Position', [ 20 60 230 230 ],'FontSize', 10 );
%-----------------------------------------------
hEd1 = uicontrol( hFig1,'Style','edit','BackgroundColor',[1 1 1], ...
'Position',[435 400 190 30],'HorizontalAlignment','left');
hEd2 = uicontrol( hFig1,'Style','edit','BackgroundColor',[1 1 1], ...
'Position',[435 320 190 30],'HorizontalAlignment','left');
hEd3 = uicontrol( hFig1,'Style','edit','BackgroundColor',[1 1 1], ...
'Position',[435 230 190 30],'HorizontalAlignment','left');
hEd4 = uicontrol( hFig1,'Style','edit','BackgroundColor',[1 1 1], ...
'Position',[435 150 190 30],'HorizontalAlignment','left')
hList = uicontrol( hFig1,'Style','listbox','Position',[485 15 140 90], ...
'String',{'sin','cos','MyFunct1','MyFunct2','f3' }, ...
'HorizontalAlignment', 'left' );
hBut1 = uicontrol( hFig1,'Style','pushbutton','Position',[60 25 140 40], ...
'String', 'GO' );
hBut2 = uicontrol( hFig1,'Style','pushbutton','Position',[240 25 140 40], ...
'String', 'CLEAR' )
hTxt1 = uicontrol( hFig1,'Style','text','BackgroundColor',[0.7 0.7 0.7], ...
'Position', [90 475 240 20],'String','Euler solution' );
hTxt2 = uicontrol( hFig1,'Style','text','BackgroundColor',[0.7 0.7 0.7], ...
'Position', [435 440 60 20],'String','X initial' );
hTxt3 = uicontrol( hFig1,'Style','text','BackgroundColor',[0.7 0.7 0.7], ...
'Position', [435 360 60 20],'String','Y initial' );
hTxt4 = uicontrol( hFig1,'Style','text','BackgroundColor',[0.7 0.7 0.7], ...
'Position', [435 260 60 20],'String','X final' );
hTxt5 = uicontrol( hFig1,'Style','text','BackgroundColor',[0.7 0.7 0.7], ...
'Position', [435 180 60 20],'String','N' );
hTxt6 = uicontrol( hFig1,'Style','text','BackgroundColor',[0 0 0], ...
'Position', [430 5 1 900] );
hTxt7 = uicontrol( hFig1,'Style','text','BackgroundColor',[0.7 0.7 0.7], ...
'Position', [435 140 240 20],'String','Choose function' );
В результате получается вот такое графическое окно:
Это окно предназначено для численного решения дифференциального уравнения
y'(x) = F(x); Xinitial < x < X final; Yinitial = y( Xinitial );
где функция F(x) выбирается из списка, расположенного в правом нижнем углу графического окна. Остальные параметры задаются с клавиатуры в редактируемых полях. Кнопка GO предназначена для начала расчётов по методу Эйлера и показа результата в виде графика на поверхности объекта Axes. Кнопка CLEAR позволяет очистить объект Axes от содержимого.
Как мы видим из рисунка предусмотрены расчёты со стандартными функциями sin(x) и cos(x), а также с собственными функциями MyFunct1(x), MyFunct2(x) и f3(x). Последние должны быть записаны в M-файлы MyFunct1.m, MyFunct2.m, f3.m.