⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zhidianyundong.m

📁 这是MATLAB的界面—GUI的几个例子
💻 M
字号:
function varargout = zhidianyundong(varargin)
% ZHIDIANYUNDONG1 M-file for zhidianyundong1.fig
%      ZHIDIANYUNDONG1, by itself, creates a new ZHIDIANYUNDONG1 or raises the existing
%      singleton*.
%
%      H = ZHIDIANYUNDONG1 returns the handle to a new ZHIDIANYUNDONG1 or the handle to
%      the existing singleton*.
%
%      ZHIDIANYUNDONG1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ZHIDIANYUNDONG1.M with the given input arguments.
%
%      ZHIDIANYUNDONG1('Property','Value',...) creates a new ZHIDIANYUNDONG1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before zhidianyundong1_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to zhidianyundong1_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

% Copyright 2002-2003 The MathWorks, Inc.

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

% Last Modified by GUIDE v2.5 19-May-2006 10:19:06

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @zhidianyundong1_OpeningFcn, ...
                   'gui_OutputFcn',  @zhidianyundong1_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 zhidianyundong1 is made visible.
function zhidianyundong1_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 zhidianyundong1 (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes zhidianyundong1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = zhidianyundong1_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
varargout{1} = handles.output;


% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1
set(handles.radiobutton1,'value',1);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);

% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',1);
set(handles.radiobutton3,'value',0);

% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton3
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',1);

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a=get(handles.radiobutton1,'value')*(10);
b=get(handles.radiobutton2,'value')*(15);
c=get(handles.radiobutton3,'value')*(20);



% V--绝对速度
% v--相对速度
% u--牵连速度,即风速
% alpha--物料初速度与x轴方向夹角
% beta--物料初速度与y轴方向夹角
% VL--漂浮速度
% V0--物料初速度
% dt--微小时间间隔
% dx--x轴微小位移
% dy--y轴微小位移
% t0--初始时间
%Vx0--x轴物料初速度
%Vy0--y轴物料初速度
% x5--x轴位移
% y5--y轴位移

%***********开始**************%
% clear
axes(handles.axes1)
N=2000;
for i=1:4 %漂浮速度VL的循环
  V0=5;
  u=(a+b+c);
  VL=[24,10,6.5,3];
  alpha=10*pi/180;
  beta=10*pi/180;
 
  Vx0=V0*cos(alpha);
  Vy0=-V0*sin(alpha);
  h=0.0001;%步长为0.0001
  k=1;
  t0=0;
  dt=h;
  x5=0;
  y5=0;
  x(i,:)=zeros(1,N);%定义2维数组,存放x方向位移
  y(i,:)=zeros(1,N);%定义2维数组,存放y方向位移 
for k=1:N %迭代次数循环
  
  %欧拉法计算公式
   Fxp=9.8-(9.8/VL(i)^2)*sqrt((Vx0+u*sin(beta))^2+(Vy0-u*cos(beta))^2)*(Vx0+u*sin(beta));%x方向加速度计算
   Fyp=0-(9.8/VL(i)^2)*sqrt((Vx0+u*sin(beta))^2+(Vy0-u*cos(beta))^2)*(Vy0-u*cos(beta));%y方向加速度计算

   Vxp=Vx0+dt*Fxp;
   Vyp=Vy0+dt*Fyp;
  %改进欧拉法计算公式
   Fxc=9.8-(9.8/VL(i)^2)*sqrt((Vxp+u*sin(beta))^2+(Vyp-u*cos(beta))^2)*(Vxp+u*sin(beta));%x方向加速度计算
   Fyc=0-(9.8/VL(i)^2)*sqrt((Vxp+u*sin(beta))^2+(Vyp-u*cos(beta))^2)*(Vyp-u*cos(beta));%y方向加速度计算
   
   Vx=Vx0+0.5*dt*(Fxp+Fxc);
   Vy=Vy0+0.5*dt*(Fyp+Fyc);
   
   dx=(Vx0+Vx)*dt*0.5;
   x5=x5+dx;%计算x轴位移
   dy=(Vy0+Vy)*dt*0.5;
   y5=y5+dy;;%计算y轴位移
   x(i,k)=x5;
   y(i,k)=y5;  
%disp(['x',num2str(k),'=',num2str(x5)])
%disp(['y',num2str(k),'=',num2str(y5)])
   if k==N
       break
   %elseif k>=(1-0)/h %如果k大于最大迭代次数,则跳出循环
     %break
   else
       k=k+1;Vx0=Vx;Vy0=Vy;
   end
end
% disp(['最大迭代次数k=',num2str(k)])
end
%figure(gcf)
%figure('color','black','NumberTitle','off','Name','x轴方向位移与y轴方向位移图')
%subplot(1,3,j)%三幅图放在一个图形里面
%figure(j)%三幅图放在三个图形里面


% hold on
  plot(y(1,:),x(1,:),'b*',y(2,:),x(2,:),'r*',y(3,:),x(3,:),'g*',y(4,:),x(4,:),'m*')
  title(['u=',num2str(u),'m/s时,x轴方向位移与y轴方向位移图'])
  xlabel('Y')%y轴坐标
  ylabel('X')%x轴坐标
  legend('小石块','饱满颗粒','不饱满颗粒','茎杆')
  axis([-0.1,0.8,0,0.3])
  grid on
  axis ij %将坐标轴的原点设置在左上角

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -