matlab 桥梁跨径组合问题GUI图形界面完成

利用上一次的源代码进行的简单界面设计
下面是效果图


接下来是图形代码

function varargout = bijiaoGUI(varargin)
% BIJIAOGUI MATLAB code for bijiaoGUI.fig
%      BIJIAOGUI, by itself, creates a new BIJIAOGUI or raises the existing
%      singleton*.
%
%      H = BIJIAOGUI returns the handle to a new BIJIAOGUI or the handle to
%      the existing singleton*.
%
%      BIJIAOGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in BIJIAOGUI.M with the given input arguments.
%
%      BIJIAOGUI('Property','Value',...) creates a new BIJIAOGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before bijiaoGUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to bijiaoGUI_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 bijiaoGUI

% Last Modified by GUIDE v2.5 13-Jul-2018 23:16:27

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @bijiaoGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @bijiaoGUI_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 bijiaoGUI is made visible.
function bijiaoGUI_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 bijiaoGUI (see VARARGIN)
set(handles.text1,'visible','off')
set(handles.text2,'visible','off')
set(handles.text4,'visible','off')
% Choose default command line output for bijiaoGUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = bijiaoGUI_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;



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- 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)

str1=get(handles.edit1,'String');
KJ=str2num(str1);
%x存放data
%寻找函数,找到所有整数的组合
%53为一跨长度可任意取值,一般跨径为40~60m
%此函数仅考虑纵向分割
%让跨径参数化

%K跨选择方程
YKJ=0.2*KJ-1
%四舍五入
YY=round(YKJ)
data = [];
for k=3:13
    for b=0:0.5:5
        a=(KJ-2*b)/k;
        if rem(a,1) ~= 0
            a;
            continue
        else
            a;b;k;
            x=[a,b,k];
            data = [data;x];
        end
    end
end
data

%筛选函数,选出更适合的组合
index=[];
A=data(:,1);
for i=1:length(A)
    if A(i)>=3 & A(i)<=7
        index=[index;i];
    else
        continue
    end
end
index

dataX=[];
for i=1:length(index)
    aa=data(index(i),:);
    dataX=[dataX;aa];
end
dataX

%平均性检测,选择比较平均的几组数据
Z=ones(1,size(dataX,1));
AA=5;BB=2.5;KK=YY;
for i=1:size(dataX,1)
    Z(i)=abs(dataX(i,1)-AA)/AA+abs(dataX(i,2)-BB)/BB+abs(dataX(i,3)-KK)/KK;
end
Z;

[F,ix]=sort(Z,'descend');
ixx=ix(1,fix(size(dataX,1)/2):size(dataX,1));
%将ixx倒叙
ixxx=fliplr(ixx);

dataXX=[];
for i=1:length(ixxx)
    p=dataX(ixxx(i),:);
    dataXX=[dataXX;p];
end
dataXX;
A2=[]
%对a打分
for i=1:size(dataXX,1)
    A2(i)=abs(dataXX(i,1)-5)/5;
end
A2
ta=tabulate(A2(:))
NZ=size(ta,1)
AAA=[];
for i =1:size(ta,1)
    for j=1:length(A2)
        if A2(j) == ta(i,1)
            AAA(j)=1-(i-1)*(1/NZ);
        end
    end
end
AAA;
B2=[];
BBB=[];
%对b打分
for i=1:size(dataXX,1)
    B2(i)=abs(dataXX(i,2)-2.5)/2.5;
end
B2;
ta2=tabulate(B2(:))
for i =1:size(ta2,1)
    for j=1:length(B2)
        if B2(j) == ta2(i,1)
            BBB(j)=1-(i-1)*(1/NZ);
        end
    end
end
BBB;
%对c打分
K2=[]
KKK=[]
for i=1:size(dataXX,1)
    K2(i)=abs(dataXX(i,3)-YY)/YY;
end
K2
ta3=tabulate(K2(:))
for i =1:size(ta3,1)
    for j=1:length(K2)
        if K2(j) == ta3(i,1)
            KKK(j)=1-(i-1)*(1/NZ);
        end
    end
end
KKK

%层次分析法
%为设置判断矩阵
%一致性指标查表,3阶Ri为0.58
%原则上CR小于0.1时,可以考虑
P=[1,5,3;
   1/5,1,1/3;
   1/3,3,1;];
n1=length(P);
ri=[0,0,0.58,0.9,1.12];
[x,y]=eig(P);
lamda=max(diag(y))
cr0=(lamda-n1)/(n1-1)/ri(n1)
ZZJG=[];
if cr0<0.1
    disp('一致性检测通过')
    %归一化处理,得出权重系数
    for i =1:n1
        for j=1:n1
            PP(i,j)=P(i,j)/sum(sum(P));
        end
    end
    PP
    H=sum(PP,2);
    for i =1:length(H)
        W(i)=H(i)/sum(H);
    end 
    %权重值
    W
    x_new=[AAA;BBB;KKK];
    PJZ=W*x_new
    [Z,xidx]=sort(PJZ,'descend');
    xidx
    for i=1:length(xidx)
        ZZJG=[ZZJG;dataXX(xidx(i),:)];
    end
    ZZJG2=ZZJG(2:size(ZZJG,1),:);
end

set(handles.text1,'visible','on')
set(handles.text2,'visible','on')
set(handles.text4,'visible','on')
set(handles.text1,'string','跨径推荐组合为:','FontSize',12);
set(handles.text2, 'string', num2str(ZZJG),'FontSize',12);
set(handles.text4,'string','分段长度   两侧长度  跨数','FontSize',12);

发布了30 篇原创文章 · 获赞 21 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/cywtiancai/article/details/81038883