No BSD License  

Highlights from
Satellite Calculator

from Satellite Calculator by Samip Malla
A GUI model for the calculation of a GEO satellite.

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

% Last Modified by GUIDE v2.5 26-Mar-2009 11:39:13

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = orbitalcalc_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 lat1_Callback(hObject, eventdata, handles)
lat1 = str2double(get(hObject,'string'));
handles.lat1=lat1;
guidata(hObject,handles)
% hObject    handle to lat1 (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 lat1 as text
%        str2double(get(hObject,'String')) returns contents of lat1 as a double


% --- Executes during object creation, after setting all properties.
function lat1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lat1 (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



function long1_Callback(hObject, eventdata, handles)
long1 = str2double(get(hObject,'string'));
handles.long1=long1;
guidata(hObject,handles)
% hObject    handle to long1 (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 long1 as text
%        str2double(get(hObject,'String')) returns contents of long1 as a double


% --- Executes during object creation, after setting all properties.
function long1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to long1 (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






function lat2_Callback(hObject, eventdata, handles)
lat2 = str2double(get(hObject,'string'));
handles.lat2=lat2;
guidata(hObject,handles)
% hObject    handle to lat2 (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 lat2 as text
%        str2double(get(hObject,'String')) returns contents of lat2 as a double


% --- Executes during object creation, after setting all properties.
function lat2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lat2 (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



function long2_Callback(hObject, eventdata, handles)
long2 = str2double(get(hObject,'string'));
handles.long2=long2;
guidata(hObject,handles)
% hObject    handle to long2 (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 long2 as text
%        str2double(get(hObject,'String')) returns contents of long2 as a double


% --- Executes during object creation, after setting all properties.
function long2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to long2 (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






function longsat_Callback(hObject, eventdata, handles)
longsat = str2double(get(hObject,'string'));
handles.longsat=longsat;
guidata(hObject,handles)
% hObject    handle to longsat (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 longsat as text
%        str2double(get(hObject,'String')) returns contents of longsat as a double


% --- Executes during object creation, after setting all properties.
function longsat_CreateFcn(hObject, eventdata, handles)
% hObject    handle to longsat (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



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


% --- Executes during object creation, after setting all properties.
function az1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to az1 (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



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


% --- Executes during object creation, after setting all properties.
function el1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to el1 (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



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


% --- Executes during object creation, after setting all properties.
function az2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to az2 (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



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


% --- Executes during object creation, after setting all properties.
function el2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to el2 (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



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


% --- Executes during object creation, after setting all properties.
function srange1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to srange1 (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



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


% --- Executes during object creation, after setting all properties.
function srange2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to srange2 (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



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


% --- Executes during object creation, after setting all properties.
function covang1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to covang1 (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



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


% --- Executes during object creation, after setting all properties.
function covang2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to covang2 (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



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


% --- Executes during object creation, after setting all properties.
function covarea1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to covarea1 (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



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


% --- Executes during object creation, after setting all properties.
function covarea2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to covarea2 (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 calculates.
function calculates_Callback(hObject, eventdata, handles)
az1=azimuth(handles.lat1,handles.long1,0,handles.longsat);
handles.B1=handles.long1-(handles.longsat)
handles.b1=rad2deg(acos(cos(deg2rad(handles.B1))*cos(deg2rad(handles.lat1))))
slantrange1=sqrt((6378)^2+(42164)^2-(2*6378*42164*cos(deg2rad(handles.b1))));
handles.slantrange1=slantrange1;
el1=rad2deg(acos((42164/handles.slantrange1)*sin(deg2rad(handles.b1))));
covang1=2*(180-(handles.b1+el1+90));
covarea1=(2*pi*6378*6378*(1-cos(deg2rad(handles.b1))));

set(handles.el1,'string',el1);
guidata(hObject,handles)
set(handles.az1,'string',az1);
guidata(hObject,handles)
set(handles.srange1,'string',slantrange1);
guidata(hObject,handles)
set(handles.covang1,'string',covang1);
guidata(hObject,handles)
set(handles.covarea1,'string',covarea1);
guidata(hObject,handles)


az2=azimuth(handles.lat2,handles.long2,0,handles.longsat);
handles.B2=handles.long2-(handles.longsat)
handles.b2=rad2deg(acos(cos(deg2rad(handles.B2))*cos(deg2rad(handles.lat2))))
slantrange2=sqrt((6378)^2+(42164)^2-(2*6378*42164*cos(deg2rad(handles.b2))));
handles.slantrange2=slantrange2;
el2=rad2deg(acos((42164/handles.slantrange2)*sin(deg2rad(handles.b2))));
covang2=2*(180-(handles.b2+el2+90));
covarea2=(2*pi*6378*6378*(1-cos(deg2rad(handles.b2))));

set(handles.el2,'string',el2);
guidata(hObject,handles)
set(handles.az2,'string',az2);
guidata(hObject,handles)
set(handles.srange2,'string',slantrange2);
guidata(hObject,handles)
set(handles.covang2,'string',covang2);
guidata(hObject,handles)
set(handles.covarea2,'string',covarea2);
guidata(hObject,handles)


totaldelay=(handles.slantrange1/3e5)+(handles.slantrange2/3e5);
set(handles.totaldelay,'string',totaldelay);
guidata(hObject,handles)

% hObject    handle to calculates (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



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


% --- Executes during object creation, after setting all properties.
function totaldelay_CreateFcn(hObject, eventdata, handles)
% hObject    handle to totaldelay (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


Contact us at files@mathworks.com