from UAV Matching and Data Base by Abdelrahman mohammed
uav matching and data base

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

% Last Modified by GUIDE v2.5 02-Aug-2008 08:45:32

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

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes p15 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
ch=0;
dlmwrite('ch',ch,';')
dlmwrite('zezo',1,';')
c=dlmread('c');
switch c
    case 11
        a1='WEIGHT';
        b1='PAYLOAD';
    case 12
        a1='WEIGHT';
        b1='CRUISING SPEED';
    case 13
        a1='WEIGHT';
        b1='RANGE';
    case 14
        a1='WEIGHT';
        b1='ENDURANCE';
    case 15
        a1='WEIGHT';
        b1='WING SPANE';
    case 16
        a1='WEIGHT';
        b1='LENGTH';
    case 17
        a1='PAYLOAD';
        b1='CRUISING SPEED';
    case 18
        a1='PAYLOAD';
        b1='RANGE';
    case 19
        a1='PAYLOAD';
        b1='ENDURANCE';
    case 20
        a1='PAYLOAD';
        b1='WING SPANE';
    case 21
        a1='PAYLOAD';
        b1='LENGTH';
        
        
    case 22
        a1='CRUISING SPEED';
        b1='RANGE';
    case 23
        a1='CRUISING SPEED';
        b1='ENDURANCE';
    case 24
        a1='CRUISING SPEED';
        b1='WING SPANE';
    case 25
        a1='CRUISING SPEED';
        b1='LENGTH';
        
        
        
    case 26
        a1='RANGE';
        b1='ENDURANCE';
    case 27
        a1='RANGE';
        b1='WING SPANE';
    case 28
        a1='RANGE';
        b1='LENGTH';
        
        
        
    case 29
        a1='ENDURANCE';
        b1='WING SPANE';
    case 30
        a1='ENDURANCE';
        b1='LENGTH';
        
        
    case 31
        a1='WING SPANE';
        b1='LENGTH';

    case 32
        a1='WEIGHT';
        b1='POWER';
        
        case 33
        a1='PAYLOAD';
        b1='POWER';
        
        case 34
        a1='CRUISING SPEED';
        b1='LENGTH';
        
        case 35
        a1='RANGE';
        b1='POWER';
        
        case 36
        a1='ENDURANCE';
        b1='POWER';
       
    
    case 37
        a1='WING SPANE';
        b1='POWER';
        
        case 38
        a1='LENGTH';
        b1='POWER';

end
handles.xlab=a1;
handles.ylab=b1;
guidata(hObject,handles)

n1=cdfread('n1');
n2=cdfread('n2');
n3=cdfread('n3');
n4=cdfread('n4');
n5=cdfread('n5');
n6=cdfread('n6');
n7=cdfread('n7');
n8=cdfread('n8');
n9=cdfread('n9');
n10=cdfread('n10');
n11=cdfread('n11');
n12=cdfread('n12');
n13=cdfread('n13');
n14=cdfread('n14');
n15=cdfread('n15');
n16=cdfread('n16');
n17=cdfread('n17');
n18=cdfread('n18');
n19=cdfread('n19');
uav=[n1;n2;n3;n4;n5;n6;n7;n8;n9;n10;n11;n12;n13;n14;n15;n16;n17;n18;n19];

%___________________________________________________
%___________________________________________________
%______________________________________
a=dlmread('a',';');
b=dlmread('b',';');
m=uav;
handles.m=m;
guidata(hObject,handles)
%___________________________________________________
%______________________________

c=find(a==0);
d=find(b==0);
a([c,d])=[];
b([c,d])=[];
m([c,d])=[];
cdfwrite('mo1',[{'1',m}])
dlmwrite('a1',a,';')
dlmwrite('b1',b,';')

axes(handles.plot_axes)
maxa=log10(a(find(a==max(a))));
mina=log10(a(find(a==min(a))));
maxb=log10(b(find(b==max(b))));
minb=log10(b(find(b==min(b))));
dlmwrite('maxa',maxa,';')
dlmwrite('mina',mina,';')
dlmwrite('maxb',maxb,';')
dlmwrite('minb',minb,';')
p = polyfit(log10(a),log10(b),1);
yy = polyval(p,log10(a));
plot(log10(a),log10(b),'*r')
hold on
plot(log10(a),yy,'k','linewidth',2)
grid on
axis([mina(1),maxa(1), minb(1), maxb(1)])
xlabel(a1,'color','w')
ylabel(b1,'color','w')

grid on


for i=1:length(a)
    
    hold on
    plot(log10(a(i)),log10(b(i)),'*r')   
    text(log10(a(i)),log10(b(i)),[num2str(i)],'color','b','fontsize',13)
     
      
end

set(handles.a1,'string',p(1));
set(handles.a2,'string',p(2));

hold off

set(handles.plot_text,'string',m)
set(handles.inp,'string',a1)
set(handles.out,'string',b1)

% --- Outputs from this function are returned to the command line.
function varargout = p15_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 ne_push.
function ne_push_Callback(hObject, eventdata, handles)
% hObject    handle to ne_push (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in pre_push.
function pre_push_Callback(hObject, eventdata, handles)
% hObject    handle to pre_push (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
ch=dlmread('ch');
if ch==1

    c=dlmread('c');
    switch c
        case 11
            a1='WEIGHT';
            b1='PAYLOAD';
        case 12
            a1='WEIGHT';
            b1='CRUISING SPEED';
        case 13
            a1='WEIGHT';
            b1='RANGE';
        case 14
            a1='WEIGHT';
            b1='ENDURANCE';
        case 15
            a1='WEIGHT';
            b1='WING SPANE';
        case 16
            a1='WEIGHT';
            b1='LENGTH';
        case 17
            a1='PAYLOAD';
            b1='CRUISING SPEED';
        case 18
            a1='PAYLOAD';
            b1='RANGE';
        case 19
            a1='PAYLOAD';
            b1='ENDURANCE';
        case 20
            a1='PAYLOAD';
            b1='WING SPANE';
        case 21
            a1='PAYLOAD';
            b1='LENGTH';


        case 22
            a1='CRUISING SPEED';
            b1='RANGE';
        case 23
            a1='CRUISING SPEED';
            b1='ENDURANCE';
        case 24
            a1='CRUISING SPEED';
            b1='WING SPANE';
        case 25
            a1='CRUISING SPEED';
            b1='LENGTH';



        case 26
            a1='RANGE';
            b1='ENDURANCE';
        case 27
            a1='RANGE';
            b1='WING SPANE';
        case 28
            a1='RANGE';
            b1='LENGTH';



        case 29
            a1='ENDURANCE';
            b1='WING SPANE';
        case 30
            a1='ENDURANCE';
            b1='LENGTH';


        case 31
            a1='WING SPANE';
            b1='LENGTH';

        case 32
            a1='WEIGHT';
            b1='POWER';

        case 33
            a1='PAYLOAD';
            b1='POWER';

        case 34
            a1='CRUISING SPEED';
            b1='LENGTH';

        case 35
            a1='RANGE';
            b1='POWER';

        case 36
            a1='ENDURANCE';
            b1='POWER';


        case 37
            a1='WING SPANE';
            b1='POWER';

        case 38
            a1='LENGTH';
            b1='POWER';
    end


    n1=cdfread('n1');
    n2=cdfread('n2');
    n3=cdfread('n3');
    n4=cdfread('n4');
    n5=cdfread('n5');
    n6=cdfread('n6');
    n7=cdfread('n7');
    n8=cdfread('n8');
    n9=cdfread('n9');
    n10=cdfread('n10');
    n11=cdfread('n11');
    n12=cdfread('n12');
    n13=cdfread('n13');
    n14=cdfread('n14');
    n15=cdfread('n15');
    n16=cdfread('n16');
    n17=cdfread('n17');
    n18=cdfread('n18');
    n19=cdfread('n19');


    %___________________________________________________
    %___________________________________________________
    %______________________________________
    
    a=dlmread('a',';');
    b=dlmread('b',';');
    m=handles.m;
    %___________________________________________________
    %______________________________

    c=find(a==0);
    d=find(b==0);
   w1=dlmread('w1');
        a([c,d,w1])=[];
        b([c,d,w1])=[];
        m([c,d,w1])=[];      

       cdfwrite('mo',[{'1',m}])
        
        dlmwrite('zezo',2,';')
        dlmwrite('a',a,';');
        dlmwrite('b',b,';');
        handles.m=m;
        guidata(hObject,handles)

        axes(handles.plot_axes)
        maxa=dlmread('maxa',';');
        mina=dlmread('mina',';');
        maxb=dlmread('maxb',';');
        minb=dlmread('minb',';');

        p = polyfit(log10(a),log10(b),1);
        yy = polyval(p,log10(a));
        plot(log10(a),log10(b),'*r')
        hold on
        plot(log10(a),yy,'k','linewidth',2)
        grid on
        axis([mina(1),maxa(1), minb(1), maxb(1)])
        xlabel(a1,'color','w')
        ylabel(b1,'color','w')

        grid on
        for i=1:length(a)

            hold on
            plot(log10(a(i)),log10(b(i)),'*r')
            text(log10(a(i)),log10(b(i)),[num2str(i)],'color','b','fontsize',13)


        end

        set(handles.a1,'string',p(1));
        set(handles.a2,'string',p(2));

        hold off

        set(handles.plot_text,'string',m)
        set(handles.inp,'string',a1)
        set(handles.out,'string',b1)

   
    ch=0;
    dlmwrite('ch',ch,';')
end
% --- Executes during object creation, after setting all properties.
function a1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to a1 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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


% --- Executes during object creation, after setting all properties.
function a2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to a2 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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




% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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


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


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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


% --- Executes on button press in geet_push.
function geet_push_Callback(hObject, eventdata, handles)
% hObject    handle to geet_push (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
inp=str2double(get(handles.inp_edit,'string'));
p(1)=str2double(get(handles.a1,'string'));
p(2)=str2double(get(handles.a2,'string'));
out=polyval(p,log10(inp));
set(handles.out_edit,'string',10^out)
axes(handles.plot_axes)
hold on
plot(log10(inp),(out),'og','linewidth',2.5)
hold off


% --- Executes on button press in rem.
function rem_Callback(hObject, eventdata, handles)
% hObject    handle to rem (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[rex,rey]=ginput(1);
x=dlmread('a',';');
y=dlmread('b',';');
subx=abs(x-(10^rex));
suby=abs(y-(10^rey));
subz=subx+suby;
w=find(subz==min(subz));
dlmwrite('w1',w,';')
ch=1;
dlmwrite('ch',ch,';')



% --- Executes on button press in rep_push.
function rep_push_Callback(hObject, eventdata, handles)
% hObject    handle to rep_push (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 zezo=dlmread('zezo');
 switch zezo
     case 2
         name=cdfread('mo');
         x_ax=dlmread('a');
         y_ax=dlmread('b');

         for i=1:length(x_ax)
             x1_ax{i}=x_ax(i);
         end
         for i=1:length(y_ax)
             y1_ax{i}=y_ax(i);
         end
         s=[name x1_ax' y1_ax'];
     case 1
         name=cdfread('mo1');
         x_ax=dlmread('a1');
         y_ax=dlmread('b1');

         for i=1:length(x_ax)
             x1_ax{i}=x_ax(i);
         end
         for i=1:length(y_ax)
             y1_ax{i}=y_ax(i);
         end
         s=[name x1_ax' y1_ax'];
 end
xlab={handles.xlab};
ylab={handles.ylab};
aircraft={'UAVS NAME'};
exce=[aircraft,xlab,ylab;s];
delete('REPORT.xls')
xlswrite('REPORT',exce)
xlswrite('REPORT',{'ABD EL-RAHMAN MOHAMMED  Email : body_tools@hotmail.com'},'sheet1','E12')



% winopen('REPORT.xls')
qwe=figure;
set(qwe,'name','REPORT1')

p = polyfit(log10(x_ax),log10(y_ax),1);
        yy = polyval(p,log10(x_ax));
        plot(log10(x_ax),log10(y_ax),'*r')
        hold on
        plot(log10(x_ax),yy,'k','linewidth',1)
        grid on

        xlabel(handles.xlab,'color','k')
        ylabel(handles.ylab,'color','k')
        grid on
 saveas(gcf,'rep1.jpg')
close REPORT1
pic2xls('rep1.jpg','REPORT.xls','Sheet1',[0 300 700 400]);

 winopen('REPORT.xls')


Contact us at files@mathworks.com