📄 one.m
字号:
function varargout = one(varargin)
% ONE M-file for one.fig
% ONE, by itself, creates a new ONE or raises the existing
% singleton*.
%
% H = ONE returns the handle to a new ONE or the handle to
% the existing singleton*.
%
% ONE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ONE.M with the given input arguments.
%
% ONE('Property','Value',...) creates a new ONE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before one_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to one_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 one
% Last Modified by GUIDE v2.5 22-Apr-2005 19:15:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @one_OpeningFcn, ...
'gui_OutputFcn', @one_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 one is made visible.
function one_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 one (see VARARGIN)
% Choose default command line output for one
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes one wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = one_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;
image(imread('system.bmp'))% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
global z
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
z=get(handles.slider1,'value');
set(handles.text2,'string',sprintf('螺旋杆的位移为%1.4g毫米',z));
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
global pb
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
pb=get(handles.slider2,'value');
set(handles.text3,'string',sprintf('阀门压力调整为%1.4g帕斯卡',pb));
% --- Executes on button press in biao2.function biao2_Callback(hObject, eventdata, handles)
global pa k r t M pcr pb x3 Mk% hObject handle to biao2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)pb=get(handles.slider2,'value');
msgbox(['当前背压为',num2str(pb),'帕斯卡'],'实时数据','help');
pa=101325; %设定大气压力
k=1.4; %常数
r=287.05; %常数
t=307; %环境温度
M=1e-5; %常数
y=1./(4/100+1); %设定减缩喷管曲线方程
a=pi*y^2; %喷管截面面积
x=101325;
while abs(x-pb)>500
M=M+1e-7;
x0=10000;
N=1000;
L=1e-3;
K=10;
j=0;
for i=1:N
x1=L*a^2*2*k./(k-1)*r*t*(pb./(pa-0.97*x0))^((k+1)./k)-(pb./(pa-0.97*x0))^((k+1)./k)./(1.37e4*M)^2;
x2=L*a^2*2*k./(k-1)*r*t*(pb./(pa-0.97*x1))^((k+1)./k)-(pb./(pa-0.97*x1))^((k+1)./k)./(1.37e4*M)^2;
x2=x2-(x2-x1)^2/(x2-2*x1+x0);
j=j+1;
if abs(x2-x0)<K
break
end
x0=x2;
end
x2;
x3=6000-x2;
p1=pa-0.97*x2;
pcr=0.528*p1;
Q=x2;
w=50000;
v=101325;
N1=10000;
j1=0;
for i1=1:N1
fm=a^2*2*k/(k-1)*r*t*((w/(pa-0.97*Q))^(2/k)-(w/(pa-0.97*Q))^((k+1)/k))-(1.37e4*M)^2*Q;
fn=a^2*2*k/(k-1)*r*t*((v/(pa-0.97*Q))^(2/k)-(v/(pa-0.97*Q))^((k+1)/k))-(1.37e4*M)^2*Q;
x=(w+v)/2;
f= a^2*2*k/(k-1)*r*t*((x/(pa-0.97*Q))^(2/k)-(x/(pa-0.97*Q))^((k+1)/k))-(1.37e4*M)^2*Q;
j1=j1+1;
if abs(f)<0.1
break
end
if f*fm<=0
v=x;
else w=x;
end
end
end
x;
M;% --- Executes on button press in yacha.function yacha_Callback(hObject, eventdata, handles)
global z U M pb x4% hObject handle to yacha (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
Mk=z./4*M;
y=1./(z./100+1);
a=pi*y^2;
t=307;
pa=101325; %设定大气压力
k=1.4; %常数
r=287.05; %常数
L=1e-3;
x0=10000;
N=1000;
K=10;
j=0;
for i=1:N
x1=L*a^2*2*k./(k-1)*r*t*(pb./(pa-0.97*x0))^((k+1)./k)-(pb./(pa-0.97*x0))^((k+1)./k)./(1.37e4*Mk)^2;
x2=L*a^2*2*k./(k-1)*r*t*(pb./(pa-0.97*x1))^((k+1)./k)-(pb./(pa-0.97*x1))^((k+1)./k)./(1.37e4*Mk)^2;
x2=x2-(x2-x1)^2/(x2-2*x1+x0);
j=j+1;
if abs(x2-x0)<K
break
end
x0=x2;
end
x2;
x3=6000-x2;
p1=pa-0.97*x2
pcr=0.528*p1
Q=x3;
w=50000;
v=101325;
N=10000;
j=0;
for i=1:N
fm= a^2*2*k/(k-1)*r*t*((w/(pa-0.97*Q))^(2/k)-(w/(pa-0.97*Q))^((k+1)/k))-(1.37e4*Mk)^2*Q;
fn= a^2*2*k/(k-1)*r*t*((v/(pa-0.97*Q))^(2/k)-(v/(pa-0.97*Q))^((k+1)/k))-(1.37e4*Mk)^2*Q;
x4=(w+v)/2;
f= a^2*2*k/(k-1)*r*t*((x4/(pa-0.97*Q))^(2/k)-(x4/(pa-0.97*Q))^((k+1)/k))-(1.37e4*Mk)^2*Q;
j=j+1;
if abs(f)<0.1
break
end
if f*fm<=0
v=x4;
else w=x4;
end
end
x4
msgbox(['当前压差为',num2str(x3),'帕斯卡'],'实时数据','help');
% --- Executes on button press in biao1.
function biao1_Callback(hObject, eventdata, handles)
global x4 pb pcr z
% hObject handle to biao1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if pb<pcr
x4=pcr;
else pb>=pcr
x4;
end
msgbox(['当前探针位置处的压力为',num2str(x4),'帕斯卡'],'实时数据','help');
% --- Executes on mouse press over axes background.function axes1_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to axes1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -