⛄一、获取代码方式

获取代码方式1: 完整代码已上传我的资源:【气动学】基于matlab GUI弹道问题(含初始角度、速度、空气阻力、水平风)【含Matlab源码 2117期】 点击上面蓝色字体,直接付费下载,即可。

获取代码方式2: 付费专栏Matlab物理应用(初级版)

备注: 点击上面蓝色字体付费专栏Matlab物理应用(初级版),扫描上面二维码,付费29.9元订阅海神之光博客付费专栏Matlab物理应用(初级版),凭支付凭证,私信博主,可免费获得1份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效); 点击CSDN资源下载链接:1份本博客上传CSDN资源代码

⛄二、部分源代码

function varargout = Main(varargin) % MAIN M-file for Main.fig % MAIN, by itself, creates a new MAIN or raises the existing % singleton*. % % H = MAIN returns the handle to a new MAIN or the handle to % the existing singleton*. % % MAIN(‘CALLBACK’,hObject,eventData,handles,…) calls the local % function named CALLBACK in MAIN.M with the given input arguments. % % MAIN(‘Property’,‘Value’,…) creates a new MAIN or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ballist_prob_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Main_OpeningFcn via varargin. % % *See GUI Options on GUIDE’s Tools menu. Choose “GUI allows only one % instance to run (singleton)”. % % See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Main

% Last Modified by GUIDE v2.5 07-Sep-2022 21:53:19

% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct(‘gui_Name’, mfilename, … ‘gui_Singleton’, gui_Singleton, … ‘gui_OpeningFcn’, @Main_OpeningFcn, … ‘gui_OutputFcn’, @Main_OutputFcn, … ‘gui_LayoutFcn’, [] , … ‘gui_Callback’, []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end

if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT

% — Executes just before Main is made visible. function Main_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 Main (see VARARGIN)

% Choose default command line output for Main handles.output = hObject;

ax2pos=get(handles.axes2,‘position’); ax2x=ax2pos(1); ax2w=ax2pos(3); alpos=get(handles.alpha,‘position’); % text(‘position’,[(alpos(1)-ax2x)/ax2w alpos(2)+alpos(4)/2],‘string’,'\alpha = ',… % ‘parent’,handles.axes2,‘VerticalAlignment’,‘middle’,‘HorizontalAlignment’,‘right’,… % ‘units’,‘normalized’,‘FontUnits’,‘normalized’,‘FontSize’,0.0286,‘interpreter’,‘tex’);

htal=text(‘position’,[(alpos(1)-ax2x)/ax2w alpos(2)+alpos(4)/2],‘string’,‘

α

=

\alpha =\;

α=’,… ‘parent’,handles.axes2,‘VerticalAlignment’,‘middle’,‘HorizontalAlignment’,‘right’,… ‘units’,‘normalized’,‘interpreter’,‘latex’,‘FontSize’,10);

%get(htal,‘FontSize’) %get(handles.figure1,‘position’)

vpos=get(handles.v,‘position’);

htv=text(‘position’,[(vpos(1)-ax2x)/ax2w vpos(2)+vpos(4)/2],‘string’,‘

V

0

=

|\overrightarrow{V_0}| =\;

∣V0​

​∣=’,… ‘parent’,handles.axes2,‘VerticalAlignment’,‘middle’,‘HorizontalAlignment’,‘right’,… ‘units’,‘normalized’,‘interpreter’,‘latex’,‘FontSize’,10);

afpos=get(handles.af,‘position’);

htfl=text(‘position’,[0.5 afpos(2)-alpos(4)],‘string’,‘

F

f

r

=

p

(

V

)

\overrightarrow{F_{fr}}=-p(\overrightarrow{V})

Ffr​

​=−p(V

)’,… ‘parent’,handles.axes2,‘VerticalAlignment’,‘middle’,‘HorizontalAlignment’,‘center’,… ‘units’,‘normalized’,‘interpreter’,‘latex’,‘FontSize’,10);

vwpos=get(handles.vw,‘position’);

htvw=text(‘position’,[(vwpos(1)-ax2x)/ax2w vwpos(2)+vwpos(4)/2],‘string’,‘

V

w

=

V_w =\;

Vw​=’,… ‘parent’,handles.axes2,‘VerticalAlignment’,‘middle’,‘HorizontalAlignment’,‘right’,… ‘units’,‘normalized’,‘interpreter’,‘latex’,‘FontSize’,10);

fud={{htal,htv,htfl,htvw}};

set(handles.figure1,‘UserData’,fud);

set(htfl,‘visible’,‘off’); set(handles.text3,‘visible’,‘off’); set(handles.p,‘visible’,‘off’); set(handles.text4,‘visible’,‘off’); set(handles.text13,‘visible’,‘off’); set(handles.m,‘visible’,‘off’); set(handles.text14,‘visible’,‘off’); set(handles.aw,‘visible’,‘off’); set(htvw,‘visible’,‘off’); set(handles.vw,‘visible’,‘off’); set(handles.text5,‘visible’,‘off’); set(handles.text7,‘visible’,‘off’);

set(handles.axes1,‘NextPlot’,‘add’);

hbd=plot(0,0,‘ob’,‘parent’,handles.axes1,‘MarkerSize’,7); %body

xlabel(handles.axes1,‘x, m’); ylabel(handles.axes1,‘y, m’);

als=get(handles.alpha,‘string’); if get(handles.rad,‘value’) al=str2num(als); else al=pi*str2num(als)/180; end V=str2num(get(handles.v,‘string’)); g=str2num(get(handles.g,‘string’));

S=V^2sin(2al)/g; H=V2*(sin(al))2/(2*g); m=max([abs(H) abs(S)]);

if cos(al)>=0 gr=plot([-m0.2 m1.2],[0 0],‘-k’,‘parent’,handles.axes1); set(handles.axes1,‘Xlim’,[-m0.1 m1.1],‘Ylim’,[-m0.1 m1.1]); else gr=plot([-m1.2 m0.2],[0 0],‘-k’,‘parent’,handles.axes1); set(handles.axes1,‘Xlim’,[-m1.1 m0.1],‘Ylim’,[-m0.1 m1.1]); end

⛄三、运行结果

⛄四、matlab版本及参考文献

1 matlab版本 2014a

2 参考文献 [1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.

3 备注 简介此部分摘自互联网,仅供参考,若侵权,联系删除

相关文章

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: