Let us worry about your assignment instead!

We Helped With This Mechanical Engineering Assignment: Have A Similar One?

SOLVED
CategoryEngineering
SubjectMechanical Engineering
DifficultyUndergraduate
StatusSolved
More InfoStatics Mechanics Homework Help
64781

Short Assignment Requirements

The task explanation is in the first file. Second file is a paper i wrote earlier and you will need the parameters in the file to do the task. Third file is from one of my colleague's work and should give an idea on the standard of the coding.

Assignment Description

CEGE301M Space Systems Coursework 1

Set: 16th December 2016

Submission: 17th February 2017

Style: report and code (latter in soft copy only)

In coursework 1 you selected a mission for which you obtained a set of orbital elements. In coursework 2 you will write a set of Matlab (or other computer language) scripts to carry out two tasks using the orbital elements:

Task 1: design a ground tracking station network of four stations, two in the northern hemisphere, two in the southern hemisphere to support the mission. For this task you want to maximise the pass time over the stations, as well as distributing them evenly along the ground track. Use a mask angle of 5° for each station.

Task 2: predict the orbit of your satellite over 24 hours from the same set of initial conditions using a Runge-Kutta 4 algorithm and two dynamic models: the first using a monopole only gravity field, and the second using a monopole model and dynamics taking into account the oblateness of the Earth. Compare the two trajectories quantifying and characterising the differences over 24 hours. Use a 10 second step size.

Detailed task descriptions and reporting elements

Task 1

Write software that propagates the orbit forwards in time by both RK4 monopole and Keplerian propagation. Run this forwards in time from the chosen initial conditions using both methods at 10 second step sizes. Compare both trajectories in inertial position and velocity at each epoch. Comment on any differences you see. The two trajectories should be very similar because both are based upon using a monopole only gravity model. This is an essential validation step to prove you have both types of propagator working properly. Plot the differences with respect to time in all of XYZ and UVW. 

Develop your code so that you can plot a satellite trajectory ground track over a map of the world. Once you have this capability you can use the tool to choose locations for the ground stations (in terms of latitude and longitude). If you find that the majority of the satellite ground track is over you are at liberty to adjust the right ascension of the ascending node () in the initial conditions until you get a more favourable pass geometry. Once you have proposed tracking station locations calculate the rise and set times of the satellite passes over each station (to say the nearest 5 or 10 seconds), as well as the duration of the pass, and the azimuth and elevation (in the tracking station topocentric basis) of the satellite when it first becomes visible. Report the results in a table. Quote the initial conditions you used and use your imagination to produce visualisations of the satellite trajectory both in the ground track and in space. You can do the propagation in either  Task 2

In task 2 you will need to use the published and normalised C2,0 geopotential coefficient – don’t forget to de-normalise the value and show in the report how you carried out the calculation.

Task 2 involves calculating two trajectories via numerical integration using the RK4 routines – one with a monopole only model, one with the monopole and taking into account oblateness over a 24 hour trajectory.

On the map the differences between the two will not be visible, so you must instead plot the trajectory differences with time in an appropriate basis. Separate notes will be provided on Moodle as to how to do this in both satellite and ground station fixed frames. Comment on the differences you see.

The treatment of time. In such problems handling time is a relatively complicated issue. For the sake of simplicity we will handle time starting at a reference epoch of t = 0, and all subsequent epochs can be stated in seconds past the initial point. You will need to calculate the Greenwich Apparent Sidereal Time, and for our purposes we will treat the initial epoch as 12 hours, 1st January 2000.

Give a written description of your program, what functions you developed, what they are supposed to do, how you checked they worked correctly. Give an overall flow diagram of the program.

Put all your code into a separate file (see naming convention below). I expect to see clearly defined header blocks for each function explaining what the function is designed to do, and what it takes as inputs and what it provides as output, along with units. I also expect to see extensive commenting in the code explaining the algorithm steps, as well as information in the comments showing what tests were carried out to ensure the code is working properly.

 

Submit to ... as a .pdf with the following file name conventions:

Surname_student-number_astro2_report.pdf

Surname_student-number_astro2_code.pdf

Where: surname = your surname and student-number = your student number

The report must be submitted in both hard and soft copy, the code only in digital format. Both of the digital files must be in .pdf only.

Guidance: No formal page limit for the report or the code. Use graphics freely (pictures, diagrams and so on from web pages, but attribute them). Cite your references comprehensively and provide a list of references at the end. Remember to start the report with an abstract, or an executive summary – do a little research on what an abstract or an executive summary should include. The abstract/executive summary should be the last thing you write.

Assignment Description

THE GALILEO PROGRAMME

XIAOHUI GONG 14010643      PERSONAL TUTOR: DR. WILLIAM SUEN

UCL DEPARTMENT OF ENGINEERING

Abstract

The Galileo Programme is the European global satellite navigation system. It will provide critical navigation information and will stand alone but also have the ability to work in cooperation with other satellite-based navigation programs. The Galileo constellation will be comprised of 24 evenly spaced satellites in three orbits. Each satellite is equipped with highly technical and advanced instruments and technology including multiple timing devices, thermal, speed, and rotation control, and multiple antennas to provide accurate data collection and transmission. The applications of the Galileo programme will grow as the constellation nears completion, a but will include navigation, remote management, time stamped communication, security, search and rescue, and location-based information.  

 

Programme Overview

            Galileo is Europe’s Global Satellite Navigation System (GNSS). GNSS refers to a constellation of satellites that transmit positioning and timing data from space. Galileo is the only civilian controlled global option. The other programmes currently in existence are American GPS and Russian GLONASS, neither of which are civilian controlled (8). However, Galileo is interoperable with both GPS and GLONASS. Galileo provides Europe with information independence, as well as a position in the GNSS global market. It provides improved access to reliable data that allows users to know their exact position and operate mobile navigation devices, it improves emergency response services, makes roads and railways more efficient, and boosts creation and innovation creating jobs (8). Overall, the programme will enable European users a competitive level of access to positioning information as their American counterparts. 

            The Galileo programme started with two test satellites that were launched in 2008 and

2015 called GIVE-B and GIOVE-A. They are both now retired. In 2011 and then again in 2012, sets of operational satellites have been initiated for the In-Orbit Validation (IOV) phase (8). The Galileo programme moved from the IOV phase to the Full Operational Capability (FOC) phase in August of 2014 when the first pair of FOC satellites were launched. Since the FOC phase started, a total of 12 satellites has been launched in sets of two (8). Three sets were launched in 2015, and two sets were launched in 2016.

When complete, the Galileo constellation will include 24 satellites spread evenly around three orbital planes inclined at an angle of 56 degrees to the equator. Galileo utilizes the newest in GNSS technology and satellites are being constantly tested for performance and efficiency. The resulting science payload and possible application are significant for both the European Science community and the vast number of users that will benefit from the availability of information. 

Instruments & Technology        

            The first in-orbit demonstrator for the Galileo system was Giove-A, which was launched in December 2005. Giove-A was launched on a Soyuz-Fregat, which reached circular orbit at an altitude of 23,258 km, inclined at 56 degrees to the Equator, and then released Giove-A (4). This initial satellite was the first of two test satellites that would be launched during the initial stage of the Galileo programme. “The Giove-A carried two redundant, small-size rubidium atomic clocks, each with a stability of 10 nanoseconds per day, and two signal Generation units, one able to generate a simple Galileo signal and the other, more representative Galileo signals” (4). There were three primary goals of the test satellite programme phase. The goals were to secure the frequencies allocated by the International Telecommunications Union (ITU) for Galileo, to demonstrate the critical technologies needed for the navigation payload, and to identify the radiation environments of the planned Galileo orbits (4). 

 Each satellite is designed essentially the same and carries the same equipment, which is protected by a casing to protect it from radiation and powered by solar arrays. The satellites weigh roughly 700 kg each and are designed to function for 12 years, which puts them on a launch and replacement rotation, so the programme will continually have sufficient functioning satellites in orbit. Each satellite contains an L-band antenna, which transmits the navigation signals in the L-band (7). A search and rescue antenna designed to pick up and send distress signals (7). Once fully operational, this function will aid significantly in search and rescue missions by providing pinpoint location accuracy of where the distress signal originated from.The search and rescue function will also be valuable for navigation over rough terrain or open water. A C-band antenna is present to receive mission data signals from uplink stations (7). The data transmitted along the C-band will include integrity information to monitoring the functioning of the satellite, so malfunctions or inaccurate data transmissions can be addressed quickly and efficiently.  There are also two S-band antennas, which are part of the telemetry, tracking and command subsystem (7). These antennas have multiple functions. They are used to measure the satellite’s altitude, receive control commands, and transmit navigational data is the C-band antenna stops working. 

The satellites contain infrared Earth sensors, visible light sun sensors, laser retroreflectors, and space radiators. The sensors ensure the satellite keeps pointing at Earth; the laser provides measurements of the satellite's altitude in centimeters, and the radiators expel excesses heat for operational temperature control (7). The laser will also be used to act as a check of the S-band antenna to ensure it is providing accurate data. The expelling of excess heat is an essential function to ensure the onboard electronics do not overheat.

Timing is an important role of the satellite and the primary means of how accurate location information is provided. Therefore, each satellite is outfitted with multiple clocks. There is the passive hydrogen maser clock, which is the primary clock. Each satellite will carry two of these for redundancy (7). According to the ESA, this particular clock uses “the ultra-stable oscillations of a hydrogen atom to measure time to within 0.45 nanoseconds over 12 hours” (7). There are also two rubidium clocks on each satellite. Again, there are two of these clocks on board for redundancy, and these clocks are smaller atomic clocks that utilize a different type of technology, which provides redundancy with the maser clocks and are accurate within 1.8 nanoseconds over 12 hours (7). Finally, there is a clock monitoring and control unit, which acts as an interface between the four onboard clocks and the navigation signal generator to ensure that if the master clock fails, the other clock will immediately take over. The high degree of redundancy with the clocks on-board demonstrates the significance of accuracy in timing.

Without absolute precision and certainty, the Galileo programme is useless. 

As mentioned, each satellite has a navigation signal generator unit, which is the instrument that creates the navigation signals transmitted to Earth. The signals are generated based on the information provided by the clock, control unit, and data uplinked from the C-band antenna on navigation and integrity (7). There are multiple processes in place to ensure consistent reporting if one instrument fails. 

Each satellite is also equipped with a gyroscope to measure the rotation of the satellite

(7). The rotation measurement is needed for control of the satellite and to ensure it is accurately placed and moving. This works in conjunction with the reaction wheels. When the reaction wheels spin, the satellite rotates in the opposite direction. This ensures the satellite rotates two times during an orbit, which allows the solar wings to consistency face the sun. If the gyroscope reveals the satellite is not rotating at the proper speed, the reaction wheels can be adjusted from Earth to change the rotation speed. There are magnetotorquers, which are also an essential part of the rotation process because they can be used to modify the speed of the reaction wheels by providing magnetism-based torque (7). 

The satellites are equipped with a power conditioning and distribution unit, which

“regulates and controls power from the solar array and batteries for distribution to all the satellite’s subsystems and payload” (7). Finally, there is an onboard computer that controls the platform and payload of the satellite. Several individual instruments work together for the satellite to operate efficiently and accurately. Timing, altitude, determination, temperature, propulsion, rotation, telemetry, and orbital parameters must all maintain absolute accuracy.

Orbital Parameters

            Orbital parameters are the elements used to accurate identify a specific orbit. For the Galileo programme, 24 satellites will be evenly placed in designated slots distributed along three orbits. Image 1 below provides a look at what the Galileo Constellation will look like once complete. Each satellite is placed in what is called a slot. These slots are pre-determined to ensure that all the satellites are evenly spaced along their orbit. Figure 1 shows the 24 slots along the three obits, as well as which slots are already filled and which slots are going to be filled. 

 

 

 

Image 1: Galileo Constellation. Source: Press briefing on launch of satellite 9 & 10. (2015). Galileo. 

Retrieved from http://galileognss.eu/2015/08/.

 

Figure 1: Galileo Constellation Slots. Source: Orbital and Technical Parameters. (2016). European Global Navigation Satellite Systems Agency. Retrieved from https://www.gsc-europa.eu/system-status/orbital-andtechnical-parameters.

While Figure 1 displays how they will be placed in the orbits, Figure 2 shows the orbital parameters used to set the constellation. Figure 1 shows the geometric properties of the orbital elements used to determine the orbit of a satellite around Earth. The properties displayed in Figure 2 include Keplerian elements. The figure shows two orbiting bodies with distinct trajectories with Earth as the center mass. Depending on the trajectories being shown, an orbit contains two sets of Keplerian elements. Two Keplerian elements displayed in Figure 2 are the apogee and the perigee, which are can each be computed from the other based on a standard gravitational parameter for the central body.

 The Galileo Constellation will be evenly spaced on three orbits to be visible from all parts of the world. As shown in image 1, the completed constellation will provide Galileo with pinpoint accuracy anywhere in the world. Orbital diagrams are limited in their ability to provide a full picture. While image 1 is generated, it provides a look at the complete constellation. Figure 2 displays one of three orbital planes that will be utilized. 

 

Figure 2: Keplerian Elements. Source: Orbital and Technical Parameters. (2016). European Global Navigation Satellite Systems Agency. Retrieved from https://www.gsc-europa.eu/system-status/orbital-and-technicalparameters.

 

When launching the satellites, there are multiple measurements and placement identifications needed. Table 1: Reference Constellation Orbital and Technical Parameters, provides the placement parameters of each of the satellites that will be part of the final Galileo Constellation. The slot numbers in Table 1 can be used to reference Figure 1 to see where each satellite will be placed. The inclination is the degree from the equator the satellite will face. They are all being placed at 56 degrees. The RAAN, Arg. Perigree and Mean Anomaly provide the Keplarian

Elements that are used for particular placement within an orbit.  

Table 1: Reference Constellation Orbital and Technical Parameters 1

SV

Satellite            Slot

ID

Launch        Semi-Major

Date               Axis (Km)

Inclination

Eccentricity

(deg)

RAAN

(deg)2

Arg.

Perigee

(deg)2

Mean

Anomaly

(deg)2,3

Nominal Slots

GSAT0101 11 B05

21.10.2011 29599.8

0.0

56.0

77.632

0.0

15.153

GSAT0102 12 B06

21.10.2011 29599.8

0.0

56.0

77.632

0.0

60.153

GSAT0103 19 C04

12.10.2012 29599.8

0.0

56.0

197.632

0.0

345.153

GSAT0104 20 C05

12.10.2012 29599.8

0.0

56.0

197.632

0.0

30.153

GSAT0203 26 B08

27.03.2015 29599.8

0.0

56.0

77.632

0.0

150.153

GSAT0204 22 B03

27.03.2015 29599.8

0.0

56.0

77.632

0.0

285.153

GSAT0205 24 A08 11.09.2015 29599.8

0.0

56.0

317.632

0.0

135.153

GSAT0206 30 A05 11.09.2015 29599.8

0.0

56.0

317.632

0.0

0.153

GSAT0208 08 C07 17.12.2015 29599.8

0.0

56.0

197.632

0.0

120.153

GSAT0209 09 C02 17.12.2015 29599.8

0.0

56.0

197.632

0.0

255.153

GSAT0210 01 A02 24.05.2016 29599.8

0.0

56.0

317.632

0.0

225.153

GSAT0211 02 A06 24.05.2016 29599.8

0.0

56.0

317.632

0.0

45.153

GSAT0207 07 C06 17.11.2016 29599.8

0.0

56.0

197.632

0.0

75.153

GSAT0212 03 C08 17.11.2016 29599.8

0.0

56.0

197.632

0.0

165.153

GSAT0213 04 C03 17.11.2016 29599.8

0.0

56.0

197.6316 0.0

300.153

GSAT0214 05 C01 17.11.2016 29599.8

Extended Slots

0.0

56.0

197.632 0.0

210.153


SV    Launch Semi-Major      Inclination RAAN Satellite         Slot             Eccentricity

                     ID           Date          Axis (Km)                      (deg)           (deg)2

Arg.

Perigee

(deg)2

Mean

Anomaly

(deg)2,3

GSAT0201 18 Ext01 22.08.2014 27977.6      0.162         49.850         52.521

56.198

316.069

GSAT0202 14 Ext02 22.08.2014 27977.6      0.162         49.850         52.521

56.198

136.069

Source: Orbital and Technical Parameters. (2016). European Global Navigation Satellite Systems Agency. Retrieved from https://www.gsc-europa.eu/system-status/orbital-and-technical-parameters.

Science Payload/Application

            Galileo has been in planning for many years as scientists have worked to perfect the instruments and technology being utilized. Galileo will include 24 operational satellites and six in-orbit spares (2). Services first became available in late 2016, and the programme is scheduled to be in full operation in 2020. As more satellites are added, and new services are tested, they will be made available.  In addition to the instruments being used in space, there are two Galileo Control Centres (GCCs), which control the satellites and provide navigation mission management (8). These centres are essential to the overall functioning of the programme. 

            The satellites work much like other satellites and information transmitters. They send messages to Earth containing the satellite’s current orbital position and the time the message was transmitted (3). The information is sent to receivers in the form of complex codes, which are deciphered and combined with the information being received from the other satellites (3). The information transmitted from multiple satellites simultaneously provides ultra-precise location information. To obtain pinpoint accuracy, the information from at least four satellites is required

(3). Once all 24 satellites are in place, there is no known limit to what Galileo will be able to do. 

The applications of Galileo are immense and consistently growing. Applications include the internet of things (IoT), location-based services (LBS), emergency, security and humanitarian services, science, environment, and weather, transportation, agriculture, fisheries, civil engineering, and critical time-reference functions. As more satellites are added, and more services are tested, the applications will increase in number as well as efficiency and accuracy.

IoT allows devices to exchange information with other devices, operators, and manufacturers. It is used to connect mobile devices and in the creation of smart appliances. Galileo will apply to IoT in that is will provide the positioning, velocity, and timing information needed increasing the number of context-aware applications (1). 

Location-based services (LBS) includes information and advertising for businesses and services that are geographically close to where an individual is physically located. This application of Galileo is beneficial for both businesses and consumers. The location-based service's application also makes Galileo directly useful in the daily lives of users by transforming the way they work, shop, and gather information (1). Location-bases services can also be utilized by tourist, hikers, and shoppers at large commercial centres.

Devices with Galileo-enabled features can be used to locate stolen items, missing pets, or even missing people (1).  The emergency, security and humanitarian applications can also aid in search and recovery missions, coast guard, border patrol, and work in harsh environments (1). Additionally, Galileo provides a global Search and Rescue (SAR) function. This is based on the operational Cospas-Sarsat system and will enable the satellites to transfer distress signals from the user transmitters to rescue co-ordination centres (2). This function furthers the potential applications.

When applied to the science environment and weather industries, Galileo can be used to provide support for scientific research by providing information in areas of meteorology, geology, geodesy, pollutants tracking, icebergs, mapping oceans, tides, sea levels, and more (1).  Galileo can provide significantly more accurate and reliable atmospheric measurements, which can provide more accurate weather reporting (1).  Finally, Galileo can be applied to improving the precision of international time standards and very long base interferometry (1).

Galileo will apply to transportation needs covering aviation, maritime, rail, vehicle, and pedestrian traffic including mapping and navigation. Galileo can also be used for fleet management and transportation security (1).  In areas of agriculture, Galileo can be used to improve the monitoring of chemicals, customized treatment, and property management. Galileo is also applicable to the fishery industry by promoting information exchange between vessels and stations, and offer improved navigation (1).  Galileo can also be used during search and rescue missions when a ship sends out a distress signal. Galileo can be applied to civil engineering by providing reliability and accuracy to digital mapping. The application can help to decrease costs and increase productivity, and Galileo can contribute to maintain quality standards across multiple projects (1). Galileo can also be used for ongoing maintenance and surveillance. 

Moreover, Galileo can be applied to time-reference functions that are crucial in a variety of different applications. This application applies to communications. Galileo timing signals are used for network management, time tagging, and calibration (Applications, 2016). It is also employed by the banking and insurance industries for electronic documents and computer files. Galileo timing signals are utilized for time stamping in electronic banking, e-commerce, stock transactions, and a range of assurance systems and services (1). Time-reference functions are also applicable to the energy industry providing accurate location systems as well as monitoring energy networks, power grids, and power lines for breaks or failures. Synchronizing all monitoring instruments provides the highest and most efficient level of oversight. Galileo is also applicable to seismic acquisition vessels and seismic streamer arrays 1).  Providing highresolution sites surveys, Galileo can identify geomorphologic and geophysical risks making drilling significantly safer (1). These are just the applications already identified. As the programme competes over the next six years, the number of applications will likely increase.  

 

 

             

References

 

1.      European Global Navigation Satellite Systems Agency, (2016). Applications. [online]. Available at: https://www.gsa.europa.eu/galileo/applications.

 

2.      European Space Agency, (2016). Galileo Navigation. [online] European Space Agency. Available at:  http://www.esa.int/Our_Activities/Navigation/Galileo/What_is_Galileo.

 

3.      European Space Agency, (2016). Navigation. [online] European Space Agency. Available at:

http://m.esa.int/Our_Activities/Navigation/How_satellite_navigation_works. 

 

4.      European Space Agency, (2005). No 61-2005: First Galileo Satellite on orbit to demonstrate key technologies. [online] European Space Agency. Available at: http://www.esa.int/For_Media/Press_Releases/First_Galileo_satellite_on_orbit_to_demonstra te_key_technologies.  

 

5.      European Global Navigation Satellite Systems Agency, (2016). Orbital and Technical Parameters. [online] European Global Navigation Satellite Systems Agency. Available at:

https://www.gsc-europa.eu/system-status/orbital-and-technical-parameters

 

6.      Galileo. (2015). Press briefing on launch of satellites 9 & 10. [online] Galileo. Available at:

http://galileognss.eu/press-briefing-on-launch-of-satellites-9-10/.

 

7.      European Space Agency, (2016). Satellite Anatomy. [online] European Space Agency. Available at: http://m.esa.int/Our_Activities/Navigation/Galileo/Satellite_anatomy.

 

 

8.      European Global Navigation Satellite Systems Agency, (2016). What is Galileo? [online] Available at:  https://www.gsceuropa.eu/galileo-overview/what-is-galileo.

 

9.      EGNOS, (2016). What is GNSS? [online] EGNOS. Available at:

        https://www.egnosportal.eu/discover-      egnos/about-egnos/what-gnss. 

 

 

Assignment Code


%************************************************************%
%**********                                    **************%
%**********                 Readme             **************%
%**********                                    **************%
%************************************************************%

%Satellie Propogation Prediction Software
%{
This software provides 3 different modes-free mode,task1, task2.
Free mode has the ability to predict the state(position and velocity) 
of satellite in specific epoch. It also provides the ground tracking ability
at user specified location. Results are presented via map plotting 
in both 3D and 2D.

Task1 mode is designed to accomplish task 1 in coursework2. It uses both 
RK4 and Keplerian propagation to predict satellite's state. Then compare
the difference in inertial position and velocity.
Then it propose a network of four ground stations which has maximum pass
time. Mean while they are distributed evenly over the ground track.
Finally, the Azimuth and elevation, and rise, set, and duration of the
satelllite of each station will be presented in a table.

Task2 mode compares the difference between RK4 and RK4-J2 algorithm. The
difference will then be plotted in a map.

Developing Environment:MATLAB R2016b academic use, Windows7 x64
Created by Jiajie Yang for CEGE301M Space System
University College London(UCL)
04/01/2017
%}

%Features and Functions
%{
1. Full Graphical User Interface
2. A wide range of variables can be specified by user, such as initial
   satellite condition, mask angle for ground track.
3. Multiple prediction algorithms - Keplerian propogation, RK4 and RK4-J2.
4. Provides a wide range of reference conversion functions - CAR2KEP,
   KEP2CAR, CAR2ECEF,...
5. Ground tracking plotting, both in 3D and 2D.

%}

%Code Structure
%{

while 1 
    Initialization
        Global variable
        User input (start GUI)
        Coding variable

    Main
        case Free mode
            core Algrithm selection

            Coordinates Conversions
            Ground Tracking
            Map Plot
        case task 1
            Keplerian Propogation
            RK4 Prediction
            Difference PLOT

            Ground Station Selection
            Map Plot
        case task 2
end

Functions
    Keplerian prediction
    RK4 prediction
    RK4-J2 prediction
    CAR2KEP conversion
    KEP2CAR conversion
    CAR2ECEF conversion
    ECEF2LLH conversion
    LLH2ECEF conversion
    Ground tracking plot
    Station visibility check
    Rise Set Duration calculation

GUI
%}

%Vesions
%{
v1.0 03/01/2017
    RK4,Kepler orbit prediction
    2D,3D groundtrack mapping
    Coordinates conversion (KEP2CAR CAR2KEP ECI2ECEF ECEF2LLH)
    Results in seperate variable - result_XXX
v1.1 03/01/2017
    Results in single struct 'result' 
    Ground tracking wrapped as a function which can be used by both RK4 and
    KEP
    Visibility check, including XECEF2LLH conversion, Elevetion and Azumith
    calculation.
    Ground track update: plot paths visibale to stations only.
v1.2 03/01/2017
    Ground track update: select between visible paths and full paths.
    RISE,SET,DURATION time calculation algrithem added.
v2.0 04/01/2017
    RK4J2 Added.
    Detailed comment added.
    Main body seperated into 2 parts 1.Prediction 2. Ground Track
    Gournd Track 4 stations, Plot multiple stations's visible path.
v2.1 04/01/2017
    UserInputBox added
    CAR2KEPSMP(K0,X) simple CAR2KEP function added
    GUI added (uncommend to use UserInput Box)
    Progress bar for prediction calculation and ground tracking added
    (commandline),shown in 100% scale bar.
    waitbar added, which is the same feature as progress bar, but in GUI
v2.2 05/01/2017
    GUI was in seperate .fig % .m files created by GUIDE.
    Now, GUI is implanted in this .m file.
v2.3 06/01/2017
    edited readme,code structure, features and functions explaination added
    Task1 mode added
    Improved GNDPLOT and VBSCHK for speed.
v2.4 08/01/2017
    New GUI, includes goound station network input, and task 1 and task2
    Gui restarts autometically after computation.
v2.5 10/01/2017
    Plot difference in XY added for task1.
%}

%************************************************************%
%************                                 ***************%
%************           Initialization        ***************%
%************                                 ***************%
%************************************************************%
while 1
    %Clear Workspace
    clear;
    
    %******Scientific constants******%
    %Scientific constants decleared in CAPITALS as global variables
    global GM;
    global RE;
    global RateE;
    global C20;
    global A_EGM96;
    global guiinput;
    
    GM= 398600.4418; %Product of gravitational constant and the mass of Earth
    RE=6367; %Radius of Earth
    RateE=(2*pi)/86400; %Rate of rotation of Earth
    C20=-0.484165371736e-3; %c2,0 constant
    A_EGM96=6378.1363;
    guiinput=zeros(1,26);
    
    
    
    %*********** User Input ***********%
    %{
User Input section collects initial data required for calculations,
includes
1.Initial condition of Keplerian Element
2.algorithm to use, either Keplerian Propogation, RK4 and RK4-J2
3.time step for propogation prediction
4.mask angle of station tracking
5.Epoch in second
6.plot selection toggle
7.tracking station location

Three Methods are provied-1. edit source code variables 2.simple prompt box
3. FULL GUI. 
Comment and uncomment to switch. FULL GUI is used by default.
    %}
    
    %Initial condition of satellit
    %Keplerian elements of Jason2
    %K0=[7719.637185686; 0.00049339; 1.1526886; 1.16148673; 3.167; 5.50189];
    %X=[-7106.35391094539;-1370.79415770783;2677.93082766212;...
    %2.79960206009417; -2.62939105228011;6.07615566226208];
    
    %Tracking station locations
    %LLH_P1=[45 180 0];
    %LLH_P2=[-45 90 0];
    %LLH_P3=[-45 270 0];
    %LLH_P4=[45 0 0];
    
    %User Input prompt box %
    %Should the Full GUI encounter any error, uncommend to use simple prompt
    %box to input data.
    %{
prompt = {'Please select prediction algorithm, 1 for Keplerian propogation, 2 for RK4, 3 for RK4-J2','Mask Angle in degrees','Time step in seconds','Epoch in Seconds'};
dlg_title = 'User Input';
num_lines = 1;
defaultans = {'1','5','10','86400'}; %default values

%Validity check, ask for input again if previous input is not valid
%Set validity flag to 0 to start the initial check
validity=0;
while validity==0
    input = inputdlg(prompt,dlg_title,num_lines,defaultans);%prompt input box
    
    %Assign value to variables
    switch_alg=str2double(cell2mat(input(1,1)));
    mask=deg2rad(str2double(cell2mat(input(2,1))));
    t=str2double(cell2mat(input(3,1)));
    epoch_s=str2double(cell2mat(input(4,1)));
    epoch_d=epoch_s/60/60/24;
    validity=1;
    
    %Validity check
    if (switch_alg~=1 && switch_alg~=2 && switch_alg~=3)
        uiwait(msgbox('Invalid prediction algorithm selection, please reselect','Error','error','modal'));
        validity=0;
    else if mask<0 || mask>pi/2
            uiwait(msgbox('Invalid mask angle','Error','error','modal'));
            validity=0;
        else if t<0 || t>100
                uiwait(msgbox('time step is smaller than 0 or too big','Error','error','modal'));
                validity=0;
            else if epoch_s<0 || epoch_s>999999999
                    uiwait(msgbox('Epoch is smaller than 0 or too big','Error','error','modal'));
                    validity=0;
                end
            end
        end
    end
    
end
    %}
    
    %FULL GUI%
    
    %Start GUI
    gui;
    %Read input from GUI
    mode=guiinput(1);
    mask=deg2rad(guiinput(2));
    t=guiinput(3);
    epoch_s=guiinput(4);
    plot3d=guiinput(5);
    plot2df=guiinput(6);
    plot2dv=guiinput(7);
    K0(1,1)=guiinput(8);
    K0(2,1)=guiinput(9);
    K0(3,1)=guiinput(10);
    K0(4,1)=guiinput(11);
    K0(5,1)=guiinput(12);
    K0(6,1)=guiinput(13);
    switch_alg=guiinput(14);
    LLH_P1(1)=guiinput(15);
    LLH_P1(2)=guiinput(16);
    LLH_P1(3)=guiinput(17);
    LLH_P2(1)=guiinput(18);
    LLH_P2(2)=guiinput(19);
    LLH_P2(3)=guiinput(20);
    LLH_P3(1)=guiinput(21);
    LLH_P3(2)=guiinput(22);
    LLH_P3(3)=guiinput(23);
    LLH_P4(1)=guiinput(24);
    LLH_P4(2)=guiinput(25);
    LLH_P4(3)=guiinput(26);
    
    %*********** Vriables for Coding ***********%
    %Vriables used for Coding purpose only, such as index, data storage.
    hold on;
    grid on;
    i=0;
    K=0;
    X=0;
    XECEF=0;
    LLH=0;
    AZMELV=0;
    STT=0;
    RSD=0;
    
    result_KEP(epoch_s/t)=struct('EPOCH',i*t,'KEP',K,'X', X);
    result_RK4(epoch_s/t)=struct('EPOCH',i*t,'KEP',K,'X', X);
    result_RK4J2(epoch_s/t)=struct('EPOCH',i*t,'KEP',K,'X', X);
    result(epoch_s/t)=struct('EPOCH',i*t,'KEP',K,'X', X, 'ECEF',...
        XECEF, 'LLH',LLH, 'AZMELV', AZMELV, 'STT', STT,'RSD',RSD);
    
    
    %************************************************************%
    %************                                 ***************%
    %************             M a i n             ***************%
    %************         3 Modes To Select       ***************%
    %************************************************************%
    
    %1.Free mode
    %2. Task 1
    %3. Task 2
    
    switch mode
        case 1
            %******************************************%
            %********         Free Mode      **********%
            %******************************************%
            
            %********Orbit prediction********%
            %1.three available algorithms each eveluate keplerian elements 'K'
            %  and Cartesian coordinations 'X' of satellite at epoches
            %  using 't' time step.
            %2.write 'Epoch', 'K' and 'X'to respective 'result_XXX'.
            %3.Pass result to 'result_EKX' for use in Ground Tracking.
            
            switch switch_alg
                %Prediction using KEP
                case 1
                    %display start message both cmd line and GUI
                    disp('KEP Prediction in use');
                    hwait=waitbar(0,'KEP Prediction in use','Name','Status', 'WindowStyle', 'modal');
                    
                    K=K0;
                    
                    for i = 1:1:(epoch_s/t)
                        %Prediction
                        X=PredictionKEP(K,t);
                        
                        %Update K for next loop
                        K=CAR2KEP(X);
                        
                        %Write result
                        result_KEP(i)=struct('EPOCH',i*t,'KEP',K,'X', X);
                        
                        %Show progress in 100% scale,both cmd line and GUI
                        if rem(i*100,epoch_s/t)==0
                            disp(['Prediction Progress ',num2str(i*100/(epoch_s/t)),'%']);
                        end
                        
                        waitbar(i / (epoch_s/t),hwait,sprintf('Prediction in Progress'));
                        
                    end
                    
                    %Show progress in 100% scale,both cmd line and GUI
                    disp('Calculation Completed! Writing results');
                    
                    waitbar(1/1,hwait,sprintf('Calculation Completed! Writing results'));
                    delete(hwait);
                    
                    result_EKX=result_KEP;
                case 2
                    disp('RK4 Prediction in use');
                    hwait=waitbar(0,'RK4 Prediction in use','Name','Status', 'WindowStyle', 'modal');
                    
                    X=KEP2CAR(K0);
                    for i = 1:1:(epoch_s/t)
                        %RK4 Prediction
                        X=RK4(X,t);
                        
                        %CAR to KEP conversion
                        K=CAR2KEP(X);
                        
                        %Write result
                        result_RK4(i)=struct('EPOCH',i*t,'KEP',K,'X', X);
                        
                        %Show progress in 100% scale,both cmd line and GUI
                        if rem(i*100,epoch_s/t)==0
                            disp(['Prediction Progress ',num2str(i*100/(epoch_s/t)),'%']);
                        end
                        
                        waitbar(i / (epoch_s/t),hwait,sprintf('Prediction in Progress'));
                        
                    end
                    
                    %Show progress in 100% scale,both cmd line and GUI
                    disp('Calculation Completed! Writing results');
                    
                    waitbar(1/1,hwait,sprintf('Calculation Completed! Writing results'));
                    delete(hwait);
                    
                    result_EKX=result_RK4;
                    
                    %Prediction using RK4-J2
                case 3
                    disp('RK4-J2 Prediction in use');
                    hwait=waitbar(0,'RK4-J2 Prediction in use','Name','Status', 'WindowStyle', 'modal');
                    
                    
                    X=KEP2CAR(K0);
                    for i = 1:1:(epoch_s/t)
                        %RK4 Prediction
                        X=RK4J2(X,t);
                        
                        %CAR to KEP conversion
                        K=CAR2KEP(X);
                        
                        %Write result
                        result_RK4J2(i)=struct('EPOCH',i*t,'KEP',K,'X', X);
                        
                        %Show progress in 100% scale,both cmd line and GUI
                        if rem(i*100,epoch_s/t)==0
                            disp(['Prediction Progress ',num2str(i*100/(epoch_s/t)),'%']);
                        end
                        
                        waitbar(i / (epoch_s/t),hwait,sprintf('Prediction in Progress'));
                        
                    end
                    
                    %Show progress in 100% scale,both cmd line and GUI
                    disp('Calculation Completed! Writing results');
                    
                    waitbar(1/1,hwait,sprintf('Calculation Completed! Writing results'));
                    delete(hwait);
                    
                    result_EKX=result_RK4J2;
            end
            
            %********Coordinates Conversions & Ground Tracking************%
            %1.Convert Earth Centered Inetial reference frame to Earth centered Earth Fixed
            %2.Convert  Earth centered Earth Fixed to Latitude Longitude Height
            %3.Calculate Azimuth and Elevation at gournd stations and Check visibility at different epoch
            %4.Calculate Rise,Set,During for each station.
            %5.Plot results in 3D, 2D full path and 2D with path visible to gound stations
            
            hwait=waitbar(0,'Ground Tracking in Progress','Name','Status', 'WindowStyle', 'modal');
            for i = 1:1:epoch_s/t
                
                %ECI to ECEF conversion
                XECEF=ECI2ECEF(result_EKX(i).X,i*t);
                
                %ECEF to LLH conversion
                LLH=ECEF2LLH(XECEF);
                
                %Calculat AZM and ELV to different stations
                AZMELV1=AZMELVCAL(LLH_P1,XECEF);
                AZMELV2=AZMELVCAL(LLH_P2,XECEF);
                AZMELV3=AZMELVCAL(LLH_P3,XECEF);
                AZMELV4=AZMELVCAL(LLH_P4,XECEF);
                
                AZMELV=[AZMELV1 AZMELV2 AZMELV3 AZMELV4];
                
                %Write result
                result(i)=struct('EPOCH',result_EKX(i).EPOCH,'KEP',result_EKX(i).KEP,'X',result_EKX(i).X, 'ECEF', XECEF, 'LLH',LLH, 'AZMELV',AZMELV,'STT',STT,'RSD',RSD);
                
                
                if rem(i*100,epoch_s/t)==0
                    disp(['Ground Tracking in Progress ',num2str(i*100/(epoch_s/t)),'%']);
                end
                
                waitbar(i / (epoch_s/t),hwait,sprintf('Ground Tracking in Progress'));
            end
            
            %Visibility Check, and write result to 'result'
            [RISE, SET, DRT, STT]=VSBCHK(result,epoch_s,t,mask);
            result(1).RSD=[RISE,SET,DRT];
            for i=1:1:epoch_s/t
                result(i).STT=STT(i,:);
            end
            
            
            %Display message
            
            disp('Ground Tracking Completed!');
            waitbar(1,hwait,sprintf('Ground Tracking Completed!'));
            delete(hwait);
            
            
            GNDPLOT(result,epoch_s,t,plot3d,plot2df,plot2dv);
            
            
        case 2
            %******************************************%
            %********          Task 1        **********%
            %******************************************%
            disp('Task1 start');
            
            %Section 1
            %1.Compare difference in Keplerian aand RK4 algorithm
            %2.Plot the difference path
            
            
            %%%%KEP Prediction
            %display start message both cmd line and GUI
            disp('KEP Prediction in use');
            hwait=waitbar(0,'KEP Prediction in use','Name','Status', 'WindowStyle', 'modal');
            
            K=K0;
            KEP_X=zeros(epoch_s/t,6);
            for i = 1:1:(epoch_s/t)
                %Kepelerian Prediction
                X=PredictionKEP(K,t);
                
                %Update K for next loop
                K=CAR2KEP(X);
                
                %Write result
                result_KEP(i)=struct('EPOCH',i*t,'KEP',K,'X', X);
                KEP_X(i,:)=X;
                
                %Show progress in 100% scale,both cmd line and GUI
                if rem(i*100,epoch_s/t)==0
                    disp(['KEP Prediction Progress ',num2str(i*100/(epoch_s/t)),'%']);
                end
                
                waitbar(i / (epoch_s/t),hwait,sprintf('KEP Prediction in Progress'));
                
            end
            
            %Show progress in 100% scale,both cmd line and GUI
            disp('KEP Calculation Completed! Writing results');
            waitbar(1/1,hwait,sprintf('KEP Calculation Completed! Writing results'));
            delete(hwait);
            
            result_EKX=result_KEP;
            
            %RK4 Prediction
            %display start message both cmd line and GUI
            disp('RK4 Prediction in use');
            hwait=waitbar(0,'RK4 Prediction in use','Name','Status', 'WindowStyle', 'modal');
            
            RK4_X=zeros(epoch_s/t,6);
            X=KEP2CAR(K0);
            for i = 1:1:(epoch_s/t)
                %RK4 Prediction
                X=RK4(X,t);
                
                %CAR to KEP conversion
                K=CAR2KEP(X);
                
                %Write result
                result_RK4(i)=struct('EPOCH',i*t,'KEP',K,'X', X);
                RK4_X(i,:)=X;
                %Show progress in 100% scale,both cmd line and GUI
                if rem(i*100,epoch_s/t)==0
                    disp(['RK4 Prediction Progress ',num2str(i*100/(epoch_s/t)),'%']);
                end
                
                waitbar(i / (epoch_s/t),hwait,sprintf('RK4 Prediction in Progress'));
                
            end
            
            %Show progress in 100% scale,both cmd line and GUI
            disp('RK4 Calculation Completed! Writing results');
            
            waitbar(1/1,hwait,sprintf('RK4 Calculation Completed! Writing results'));
            delete(hwait);
            
            %%%%Comparasion between KEP and RK4
            
            compare_X=KEP_X-RK4_X;
            
            %Plot Difference on map
            hwait=waitbar(0,'Ground Tracking in Progress','Name','Status', 'WindowStyle', 'modal');
            VSB=zeros(epoch_s/t);
            for i = 1:1:(epoch_s/t)
                
                %ECI to ECEF conversion
                XECEF=ECI2ECEF(result_EKX(i).X,i*t);
                
                %ECEF to LLH conversion
                LLH=ECEF2LLH(XECEF);
                
                
                
                %Check visibility If difference >0.01,use VSB as switch, 1 for plot, 0 for not plot
                if   abs(compare_X(i,1))>0.01 || abs(compare_X(i,2))>0.01 || abs(compare_X(i,3)>0.01)
                    VSB(i)=1;
                else
                    VSB(i)=0;
                end
                
                
                %Write result
                result(i)=struct('EPOCH',result_EKX(i).EPOCH,'KEP',result_EKX(i).KEP,'X',result_EKX(i).X, 'ECEF', XECEF, 'LLH',LLH, 'AZMELV',AZMELV,'STT',STT,'RSD',RSD);
                
                %Show progress
                if rem(i*100,epoch_s/t)==0
                    disp(['Ground Tracking Progress ',num2str(i*100/(epoch_s/t)),'%']);
                end
                
                waitbar(i / (epoch_s/t),hwait,sprintf('Ground Tracking in Progress'));
                
            end
            %Display message
            disp('Ground Tracking Completed!');
            waitbar(1,hwait,sprintf('Ground Tracking Completed!'));
            delete(hwait);
            
            %Plot difference
            GNDPLOTDIF(VSB,result,epoch_s,t);
            
            
            %Plot difference on 2D axis
            figure('Name','Difference Plot');
            hold on;
            plot_x=linspace(0,epoch_s,epoch_s/t);
            plot_y1=compare_X(:,1);
            plot_y2=compare_X(:,2);
            plot_y3=compare_X(:,3);
            plot(plot_x,plot_y1,'DisplayName','X');
            plot(plot_x,plot_y2,'DisplayName','Y');
            plot(plot_x,plot_y3,'DisplayName','Z');
            
            %Section 2
            
            %Station Finding
            %1.Find the the max and min latitude
            %2.place the station at the 1/3 and 2/3 point
            lat=zeros(epoch_s/t);
            for i=1:1:epoch_s/t
                lat(i)=result(i).LLH(1);
            end
            max_lat=rad2deg(max(lat));
            min_lat=rad2deg(min(lat));
            
            distance_lat=(max_lat-min_lat)/3;
            lat1=min_lat+distance_lat;
            lat2=min_lat+2*distance_lat;
            lat3=lat1;
            lat4=lat2;
            
            LLH_P1=[lat1(1),0,0];
            LLH_P2=[lat2(1),90,0];
            LLH_P3=[lat3(1),180,0];
            LLH_P4=[lat4(1),270,0];
            
 
            
            %AZM ELV calculation
            for i=1:1:epoch_s/t
                %Check visibility
                XECEF=result(i).ECEF;
                AZMELV1=AZMELVCAL(LLH_P1,XECEF);
                AZMELV2=AZMELVCAL(LLH_P2,XECEF);
                AZMELV3=AZMELVCAL(LLH_P3,XECEF);
                AZMELV4=AZMELVCAL(LLH_P4,XECEF);
                
                AZMELV=[AZMELV1 AZMELV2 AZMELV3 AZMELV4];
                result(i).AZMELV=AZMELV;
            end
            [RISE, SET, DRT, STT]=VSBCHK(result,epoch_s,t,mask);
            result(1).RSD=[RISE,SET,DRT];
            
            for i=1:1:epoch_s/t
                result(i).STT=STT(i,:);
            end
            
            %GET AZM ELV at RISE epoch
            AZM=zeros(4);
            ELV=zeros(4);
            for i=1:1:4
                if RISE(1,i)~=0
                    AZM(i)=rad2deg(result(RISE(1,i)/t).AZMELV(i*2-1));
                    ELV(i)=rad2deg(result(RISE(1,i)/t).AZMELV(i*2));
                end
            end
            
            GNDPLOT(result,epoch_s,t,0,0,1)
            %Export Results
            table_figure=figure;
            t=uitable(table_figure);
            table_data(:,1)=[1,2,3,4];
            table_data(:,2)=transpose(RISE(1,:));
            table_data(:,3)=transpose(SET(1,:));
            table_data(:,4)=transpose(DRT(1,:));
            table_data(:,5)=transpose(AZM(1,:));
            table_data(:,6)=transpose(ELV(1,:));
            
            t.Position = [0 0 500 400];
            t.ColumnName = {'Station', 'Rise epoch','Set epoch','Duration','Azimuth','Elevation'};
            t.Data=table_data;
            
            
        case 3
            %******************************************%
            %********          Task 2        **********%
            %******************************************%
    end
    
    %Clean workspace
    clear;
    
    disp('Exit Programme and restart GUI');
    
    
end
%************************************************************%
%************                                 ***************%
%************             Functions           ***************%
%************                                 ***************%
%************************************************************%

%KEP2CAR Keplerian elements to Cartesian vectors conversion function
function X=KEP2CAR(K)
    %***Initialization***%
    global GM;%Product of gravitational constant and the mass of Earth
    
    sma=K(1); %semi major axis
    ecc=K(2); %Eccentricity
    inc=K(3); %inclination
    argp=K(4);%argument of perigee
    raan=K(5);%Rright ascention of ascending node
    tran=K(6);%true anomaly
    

    %***Position Vector Calculation**  *%
    p=[cos(raan)*cos(argp)-sin(raan)*cos(inc)*sin(argp) ;
        sin(raan)*cos(argp)+cos(raan)*cos(inc)*sin(argp) ;
        sin(inc)*sin(argp)]; %In-orbital plane Gaussian Vector

    q=[-cos(raan)*sin(argp)-sin(raan)*cos(inc)*cos(argp) ;
        cos(raan)*cos(inc)*cos(argp)-sin(raan)*sin(argp) ;
        sin(inc)*cos(argp)]; %In-orbital plane Gaussian Vector

    rho=sma*(1-ecc^2);      %semi-latus rectum
    r=rho/(1+ecc*cos(tran));%radial distance

    x=r*cos(tran);          %x coordinates in orbital basis
    y=r*sin(tran);          %y coordinates in orbital basis

    %Calculate the position vector in ECI basis
    X=x*p+y*q;

    %**Velocity Vector Calculation**%
    cose=x/sma+ecc;%cos of eccentricty anomaly
    sine=y/(sma*sqrt(1-ecc^2));%sin of eccentricty anomaly

    f=sqrt(sma*GM)/r;
    g=sqrt(1-ecc^2);

    %Calculate the velocity vector in ECI basis
    V=-f*sine*p+f*g*cose*q;

    %Combine the position vector and the velocity vector in to X

    X=[X(1);X(2);X(3);V(1);V(2);V(3)];

end

%CAR2KEP Cartesian vectors to Keplerian elements conversion function
function K=CAR2KEP(X)
%***Initialization***%
    global GM; %Product of gravitational constant and the mass of Earth
    
    %Caresian position vector
    x(1)=X(1); 
    x(2)=X(2);
    x(3)=X(3); 
    %Caresian velocity vector
    v(1)=X(4);
    v(2)=X(5);
    v(3)=X(6);
    
    %Orbital normal vector
    h= cross(x,v);
    %modules of h
    modh=sqrt(h(1)^2+h(2)^2+h(3)^2);
    %Unit Orbital normal vector
    w=h/modh;
    
    %Calculate inclination
    inc=atan(sqrt(w(1)^2+w(2)^2)/w(3));
    
    %Calculate RAAN
    raan=atan2(w(1),-w(2));
    if raan<0
        raan=raan+2*pi;
    end
    %Calculate semi major axis
    r=sqrt(x(1)^2+x(2)^2+x(3)^2);
    velocity=sqrt(v(1)^2+v(2)^2+v(3)^2);
    
    sma=1/(2/r-velocity^2/GM);
    
    %Calculate eccentricity
    ecc=sqrt(1-modh^2/(GM*sma));
   
    %Calculate true anomaly
    
    n=sqrt(GM/sma^3);
    E=atan2(dot(x,v)/(sma^2*n)/ecc,(1-r/sma)/ecc);
    tran=atan2(sma*sqrt(1-ecc^2)*sin(E),sma*(cos(E)-ecc));
    if tran<0
        tran=tran+2*pi;
    end
    %Calculate argument of perigee
    
    argl=atan2(x(3)/(r*sin(inc)),(x(1)*cos(raan)+x(2)*sin(raan))/r);%argument of latitude
    if argl<0
        argl=argl+2*pi;
    end
    
    
    argp=argl-tran;
    if argp<0
        argp=argp+2*pi;
    end
    
    %Output results
    K(1)=sma;
    K(2)=ecc;
    K(3)=inc;
    K(4)=argp;
    K(5)=raan;
    K(6)=tran;
    
end

%CAR2KEP Cartesian vectors to Keplerian elements conversion function
%Simple version, it calculates true anomaly only as others remain unchange
%{
function K=CAR2KEPSMP(K0,X)
%***Initialization***%
    global GM; %Product of gravitational constant and the mass of Earth
    
    %Caresian position vector
    x(1)=X(1); 
    x(2)=X(2);
    x(3)=X(3); 
    %Caresian velocity vector
    v(1)=X(4);
    v(2)=X(5);
    v(3)=X(6);

    %Calculate true anomaly
    sma=K0(1);
    ecc=K0(2);
    r=sqrt(x(1)^2+x(2)^2+x(3)^2);
    n=sqrt(GM/sma^3);
    E=atan2(dot(x,v)/(sma^2*n)/ecc,(1-r/sma)/ecc);
    tran=atan2(sma*sqrt(1-ecc^2)*sin(E),sma*(cos(E)-ecc));
    if tran<0
        tran=tran+2*pi;
    end
    
    %Output results
    K=K0;
    K(6)=tran;
    
end
%}

%Orbit prediction function via Keplerian propagation
function X=PredictionKEP(K,t)
%***Initialization***%
    global GM; %declear the value of GM

    sma=K(1); %semi major axis
    ecc=K(2); %Eccentricity
    inc=K(3); %inclination
    argp=K(4);%inclination
    raan=K(5);%Rright ascention of ascending node
    tran=K(6);%true anomaly

%***Calcualte variables (ei and mi) at required epoch ***%

    %Calculate radial distance r
    X=KEP2CAR(K);
    r=sqrt(X(1)^2+X(2)^2+X(3)^2);

    %Calculate values of mean motion n, cose0, sine0 and e0
    n=sqrt(GM/sma^3);
    cose0=r*cos(tran)/sma+ecc;
    sine0=r*sin(tran)/(sma*sqrt(1-ecc^2));
    e0=atan2(sine0,cose0);  %eccentricty anomaly at start epoch

    %if e0 is negative, then +2PI make it positive
    if e0<0
        e0=e0+2*pi;
    end

    %Mean anomaly at inital epoch
    m0=e0-ecc*sine0;

    % Mean anomaly at required epoch
    mi=m0+n*t;
    %Solve Kepler's equation to find the eccentric anomaly at required epoch
    ei=solvekepler(e0,mi,ecc);
    x=sma*(cos(ei)-ecc);
    y=sma*sqrt(1-ecc^2)*sin(ei);

%***Position Vector Calculation***%
    p=[cos(raan)*cos(argp)-sin(raan)*cos(inc)*sin(argp) ;
        sin(raan)*cos(argp)+cos(raan)*cos(inc)*sin(argp) ;
        sin(inc)*sin(argp)]; %In-orbital plane Gaussian Vector

    q=[-cos(raan)*sin(argp)-sin(raan)*cos(inc)*cos(argp) ;
        cos(raan)*cos(inc)*cos(argp)-sin(raan)*sin(argp) ;
        sin(inc)*cos(argp)]; %In-orbital plane Gaussian Vector
    %Calculate the position vector in ECI basis
    X=x*p+y*q;
    
%***Velocity Vector Calculation***%
    r=sma*(1-ecc*cos(ei));
    xdot=-sqrt(sma*GM)*sin(ei)/r;
    ydot=sqrt(sma*GM)*sqrt(1-ecc^2)*cos(ei)/r;

    %Calculate the velocity vector in ECI basis
    V=xdot*p+ydot*q;

%***Combine the position vector and the velocity vector in to X***%

    X=[X(1);X(2);X(3);V(1);V(2);V(3)];
    

end

%numeriacal Kepler equation solver
function ei=solvekepler(e0,mi,ecc)
    %Initialize
    ei=e0;
    error=1;

    %while error is greater then 0.001, coutinue finding ei
    while error > 0.001
        ei=ei-(ei-ecc*sin(ei)-mi)/(1-ecc*cos(ei));
        error=ei-ecc*sin(ei)-mi;
    end
end

%Orbit prediction function via RK4
function X=RK4(X,h)
    
    x0=X(1);  
    y0=X(2);
    z0=X(3);
    u0=X(4);
    v0=X(5);
    w0=X(6);
    global GM;
    
    %K1
    r0=sqrt(x0^2+y0^2+z0^2);
    k1x=0.5*h^2*(-GM*x0)/r0^3;
    k1y=0.5*h^2*(-GM*y0)/r0^3;
    k1z=0.5*h^2*(-GM*z0)/r0^3;
    
    
    %K2
    xk2=x0+h/2*u0+k1x/4;
    yk2=y0+h/2*v0+k1y/4;
    zk2=z0+h/2*w0+k1z/4;
    rk2=sqrt(xk2^2+yk2^2+zk2^2);
    
    k2x=0.5*h^2*(-GM*xk2)/rk2^3;
    k2y=0.5*h^2*(-GM*yk2)/rk2^3;
    k2z=0.5*h^2*(-GM*zk2)/rk2^3;
    
    %K3
    xk3=xk2;
    yk3=yk2;
    zk3=zk2;
    rk3=rk2;
    
    k3x=0.5*h^2*(-GM*xk3)/rk3^3;
    k3y=0.5*h^2*(-GM*yk3)/rk3^3;
    k3z=0.5*h^2*(-GM*zk3)/rk3^3;
    
    %k4
    xk4=x0+h*u0+k3x;
    yk4=y0+h*v0+k3y;
    zk4=z0+h*w0+k3z;
    rk4=sqrt(xk4^2+yk4^2+zk4^2);
    
    k4x=0.5*h^2*(-GM*xk4)/rk4^3;
    k4y=0.5*h^2*(-GM*yk4)/rk4^3;
    k4z=0.5*h^2*(-GM*zk4)/rk4^3;
    
    %p
    px=1/3*(k1x+k2x+k3x);
    py=1/3*(k1y+k2y+k3y);
    pz=1/3*(k1z+k2z+k3z);
    
    %q
    qx=1/3*(k1x+2*k2x+2*k3x+k4x);
    qy=1/3*(k1y+2*k2y+2*k3y+k4y);
    qz=1/3*(k1z+2*k2z+2*k3z+k4z);
    
    %Collect results
    X(1)=x0+h*u0+px;
    X(2)=y0+h*v0+py;
    X(3)=z0+h*w0+pz;
    
    X(4)=u0+qx/h;
    X(5)=v0+qy/h;
    X(6)=w0+qz/h;
    
    
end

%Orbit prediction function via RK4-J2
function X=RK4J2(X,h)
    global A_EGM96;
    global C20;
    global GM;
    a=A_EGM96;
    
    x0=X(1);  
    y0=X(2);
    z0=X(3);
    u0=X(4);
    v0=X(5);
    w0=X(6);
    
    %K1
    r0=sqrt(x0^2+y0^2+z0^2);
    k1x=0.5*h^2*((-GM*x0)/r0^3+3/2*GM*a^2/r0^5*C20*x0*(1-5*z0^2/r0^2));
    k1y=0.5*h^2*((-GM*y0)/r0^3+3/2*GM*a^2/r0^5*C20*y0*(1-5*z0^2/r0^2));
    k1z=0.5*h^2*((-GM*z0)/r0^3+3/2*GM*a^2/r0^5*C20*z0*(3-5*z0^2/r0^2));
    
    
    %K2
    xk2=x0+h/2*u0+k1x/4;
    yk2=y0+h/2*v0+k1y/4;
    zk2=z0+h/2*w0+k1z/4;
    rk2=sqrt(xk2^2+yk2^2+zk2^2);
    
    k2x=0.5*h^2*((-GM*xk2)/rk2^3+3/2*GM*a^2/rk2^5*C20*xk2*(1-5*zk2^2/rk2^2));
    k2y=0.5*h^2*((-GM*yk2)/rk2^3+3/2*GM*a^2/rk2^5*C20*yk2*(1-5*zk2^2/rk2^2));
    k2z=0.5*h^2*((-GM*zk2)/rk2^3+3/2*GM*a^2/rk2^5*C20*zk2*(3-5*zk2^2/rk2^2));
    
    %K3
    xk3=xk2;
    yk3=yk2;
    zk3=zk2;
    rk3=rk2;
    
    k3x=0.5*h^2*((-GM*xk3)/rk3^3+3/2*GM*a^2/rk3^5*C20*xk3*(1-5*zk3^2/rk3^2));
    k3y=0.5*h^2*((-GM*yk3)/rk3^3+3/2*GM*a^2/rk3^5*C20*yk3*(1-5*zk3^2/rk3^2));
    k3z=0.5*h^2*((-GM*zk3)/rk3^3+3/2*GM*a^2/rk3^5*C20*zk3*(3-5*zk3^2/rk3^2));
    
    %k4
    xk4=x0+h*u0+k3x;
    yk4=y0+h*v0+k3y;
    zk4=z0+h*w0+k3z;
    rk4=sqrt(xk4^2+yk4^2+zk4^2);
    
    k4x=0.5*h^2*((-GM*xk4)/rk4^3+3/2*GM*a^2/rk4^5*C20*xk4*(1-5*zk4^2/rk4^2));
    k4y=0.5*h^2*((-GM*yk4)/rk4^3+3/2*GM*a^2/rk4^5*C20*yk4*(1-5*zk4^2/rk4^2));
    k4z=0.5*h^2*((-GM*zk4)/rk4^3+3/2*GM*a^2/rk4^5*C20*zk4*(3-5*zk4^2/rk4^2));
    
    %p
    px=1/3*(k1x+k2x+k3x);
    py=1/3*(k1y+k2y+k3y);
    pz=1/3*(k1z+k2z+k3z);
    
    %q
    qx=1/3*(k1x+2*k2x+2*k3x+k4x);
    qy=1/3*(k1y+2*k2y+2*k3y+k4y);
    qz=1/3*(k1z+2*k2z+2*k3z+k4z);
    
    %Collect results
    X(1)=x0+h*u0+px;
    X(2)=y0+h*v0+py;
    X(3)=z0+h*w0+pz;
    
    X(4)=u0+qx/h;
    X(5)=v0+qy/h;
    X(6)=w0+qz/h;
    
    
end

%Earth Centered Inetrial reference frame to Earth Centered Earth Fix
%reference frame Conversion
function XECEF=ECI2ECEF(X,epoch)
    global RateE;
    %epoch in days
    epoch_d=epoch/60/60/24;
    GAST=deg2rad(280.4606+360.9856473662*epoch_d);
    Rz=[cos(GAST) sin(GAST) 0; -sin(GAST) cos(GAST) 0; 0 0 1];
    Xi=[X(1); X(2); X(3)];
    Xf=Rz*Xi;

    Vi=[X(4); X(5); X(6)];
    Rzdot=[-RateE*sin(GAST) RateE*cos(GAST) 0; -RateE*cos(GAST) -RateE*sin(GAST) 0; 0 0 0];

    Vf=Rzdot*Xi+Rz*Vi;
    XECEF=[Xf(1); Xf(2); Xf(3); Vf(1); Vf(2); Vf(3)];

end

%Earth Centered Earth Fix reference frame to Latitude Longitude Height
function LLH=ECEF2LLH(XECEF)
    global RE;
    lon=atan2(XECEF(2),XECEF(1));
    if lon<0
        %lon=lon+pi/2;
    end
    lat=atan(XECEF(3)/sqrt(XECEF(1)^2+XECEF(2)^2));
    height=sqrt(XECEF(1)^2+XECEF(2)^2+XECEF(3)^2)-RE;
    
    LLH=[lat lon height];
end

%Latitude Longitude Height to Earth Centered Earth Fix reference frame
function XECEF=LLH2ECEF(LLH)
    global RE;
    
    lat=LLH(1);
    lon=LLH(2);
    height=LLH(3);
    
    r=RE+height;
    z=r*sin(deg2rad(lat));
    y=r*cos(deg2rad(lat))*sin(deg2rad(lon));
    x=r*cos(deg2rad(lat))*cos(deg2rad(lon));
    
    XECEF(1)=x;
    XECEF(2)=y;
    XECEF(3)=z;
end

%Ground Tracking Plot
function GNDPLOT(result,epoch_s,t,plot3d,plot2df,plot2dv)
    global RE;
    
    %Display message
    disp('Ground Tracking Ploting');
    hwait=waitbar(0,'Ground Track Plotting','Name','Status','WindowStyle', 'modal');
    
    %***3D***%
    if plot3d==1

        %Plot Earth on 3D space
        
        [x,y,z] = sphere;
        %hfig_3d=figure('Name','3D Path');
        surf(x*RE,y*RE,z*RE);
        %Read XECEF data
        XECEF=zeros(epoch_s/t,6);

        for i=1:1:epoch_s/t
            %Read XECEF data
            XECEF(i,:)=result(i).ECEF;
            %Plot points
            %figure(hfig_3d);
            plot3(XECEF(i,1),XECEF(i,2),XECEF(i,3),'.');
            %drawnow;
            waitbar(i/(epoch_s/t),hwait,sprintf('Plotting 3D path'));

        end
    end

    %***2D FULL***%
    if plot2df==1
        %Display message
        disp('Preparing world map for 2D full path plot');
        waitbar(0,hwait,sprintf('Preparing world map for 2D full path plot'));

        %Prepare World Map
        hfig_2df=figure('Name','2D Full Path');

        ax = worldmap('World');
        setm(ax, 'Origin', [0 180 0])
        land = shaperead('landareas', 'UseGeoCoords', true);
        geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5])

        station1_lat=[-2 2 2 -2 -2];
        station1_lon=[178 178 182 182 178];
        geoshow(ax, station1_lat,station1_lon)

        %Read LLH data
        LLH=zeros(1,3);
        
        %Display message
        disp('Plotting full path');

        %Full path
        figure(hfig_2df);
        for i=1:1:epoch_s/t
            LLH(i,:)=result(i).LLH;
            waitbar(i/(epoch_s/t),hwait,sprintf('Plotting 2D full path'));
        end
        
        lat=rad2deg(LLH(:,1));
        lon=rad2deg(LLH(:,2));
        geoshow(ax, lat, lon, 'Color', 'red');
    end
    
    %***2D Path Visible to Station Only***%

    if plot2dv==1
        %Display message
        disp('Preparing world map for 2D path visible to stations');
        waitbar(0,hwait,sprintf('Preparing world map for 2D path visible to stations'));
        %Prepare World Map
        
        hfig_2dv=figure('Name','2D Path Visible to Station');
        ax = worldmap('World');
        setm(ax, 'Origin', [0 180 0])
        land = shaperead('landareas', 'UseGeoCoords', true);
        geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5])

        %station1_lat=[-2 2 2 -2 -2];
        %station1_lon=[178 178 182 182 178];
        %geoshow(ax, station1_lat,station1_lon)

        %Display message
        disp('Plotting path visible to stations');
        
        
        RSD=result.RSD;
        RISE=RSD(:,1:4);
        SET=RSD(:,5:8);
        %Read LLH data
        for i=1:1:4
           
            for j=1:1:size(RISE,1)
                start=RISE(j,i)/t;
                stop=SET(j,i)/t;
                
                if stop == 999999/t
                    stop=epoch_s/t;
                end
                
                               
                if start~=0 && stop~=0
                     lat=zeros(1,stop-start+1);
                     lon=zeros(1,stop-start+1);
                                       
                    
                    for k=1:1:(stop-start+1)
                        
                        lat(k)=rad2deg(result(start+k-1).LLH(1));
                        lon(k)=rad2deg(result(start+k-1).LLH(2));
                    end
                        geoshow(ax, lat, lon, 'Color', 'red');
                    waitbar((i*4+j)/(4*size(RISE,1)),hwait,sprintf('Plotting 2D Path Visible to Station'));
                end
                
            end
            
        end
       

    end
    disp('Plotting Complete');
    delete(hwait);
end

%Ground Tracking Plot for task 1
function GNDPLOTDIF(VSB,result,epoch_s,t)

%Display message
disp('Ground Tracking Ploting');
hwait=waitbar(0,'Ground Track Plotting','Name','Status','WindowStyle', 'modal');

%***2D FULL***%
%Display message
disp('Preparing world map for 2D full path plot');
waitbar(0,hwait,sprintf('Preparing world map for 2D full path plot'));

%Prepare World Map
hfig_2df=figure('Name','2D Full Path');

ax = worldmap('World');
setm(ax, 'Origin', [0 180 0])
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5])

%Read LLH data
LLH=zeros(1,3);

%Display message
disp('Plotting full path');

%Full path
figure(hfig_2df);
for i=1:1:epoch_s/t
    LLH(i,:)=result(i).LLH;
    waitbar(i/(epoch_s/t),hwait,sprintf('Plotting 2D full path'));
end

lat=rad2deg(LLH(:,1));
lon=rad2deg(LLH(:,2));
geoshow(ax, lat, lon, 'Color', 'red');
%***2D Path Difference***%
%Display message
disp('Preparing world map for 2D path showing difference');
waitbar(0,hwait,sprintf('Preparing world map for 2D path showing difference'));
%Prepare World Map

hfig_2dv=figure('Name','2D Path showing difference');
ax = worldmap('World');
setm(ax, 'Origin', [0 180 0])
land = shaperead('landareas', 'UseGeoCoords', true);
geoshow(ax, land, 'FaceColor', [0.5 0.7 0.5])

%Display message
disp('Plotting path showing difference');

figure(hfig_2dv);

count=1;
lat=0;
lon=0;
LLH=zeros(1,3);        
for i=1:1:epoch_s/t-1
    if VSB(i)==1
        
        LLH(count,:)=result(i).LLH(:);
        count=count+1;
        waitbar(i/(epoch_s/t),hwait,sprintf('Plotting 2D full path'));
        %if the difference is not visible anymore, plot the difference and reset variables
        if VSB(i+1)==0
            lat=rad2deg(LLH(:,1));
            lon=rad2deg(LLH(:,2));
            geoshow(ax, lat, lon, 'Color', 'red');
            lat=0;
            lon=0;
            LLH=zeros(1,3);
            count=1;
            
        end
        
    end
end
disp('Plotting Complete');
delete(hwait);
end

%Satellite to Ground station Azmiuth and Elevation calculation 
function AZMELV=AZMELVCAL(LLH_P,XECEF_S)
    lon=deg2rad(LLH_P(2));
    lat=deg2rad(LLH_P(1));
    XECEF_P=LLH2ECEF(LLH_P);
    XECEF_S=[XECEF_S(1) XECEF_S(2) XECEF_S(3)];
    
    P2S=XECEF_S-XECEF_P;
    P2S_hat=P2S/sqrt(P2S(1)^2+P2S(2)^2+P2S(3)^2);
    
    e_hat=[-sin(lon),cos(lon),0];
    n_hat=[-cos(lon)*sin(lat),-sin(lon)*sin(lat),cos(lat)];
    u_hat=[cos(lon)*cos(lat),sin(lon)*cos(lat),sin(lat)];
    
    P2S_e=dot(P2S_hat,e_hat);
    P2S_n=dot(P2S_hat,n_hat);
    P2S_u=dot(P2S_hat,u_hat);
    
    elv=asin(P2S_u);
    azm=atan2(P2S_e,P2S_n);
    
    
    AZMELV(1)=azm;
    AZMELV(2)=elv;
end

%Visibility Check and Rise,set,duration calculation.
function [RISE, SET, DRT, STT]=VSBCHK(result,epoch_s,t,mask)
%total number of stations
STT_NO=(size(result(1).AZMELV,2))/2;
azm=zeros(epoch_s/t,STT_NO);
elv=zeros(epoch_s/t,STT_NO);
STT=zeros(epoch_s/t,STT_NO);

%Extrac elevation for each station at all epoch
%Check visibility for each station at all epoch
for i=1:1:epoch_s/t
    for j=1:1:STT_NO
        elv(i,j)=result(i).AZMELV(2*j);
        if elv(i,j)> mask
            STT(i,j)=1;
        else
            STT(i,j)=0;
        end
    end
end

%Calculate Rise Set Duration time
%For station 1 to station STT_NO
count=1;
for i=1:1:STT_NO
    for j=1:1:epoch_s/t-1
        %If enter stations's veiw, record epoch.
        %Else If exit stations's veiw, record set time, calculate duration and increase count
        %by 1 as one visible path completes
                    
        if ((STT(j,i) == 0) && (STT(j+1,i) ~= 0))
            RISE(count,i)=result(j).EPOCH;
            
        else if ((STT(j,i) ~= 0) && (STT(j+1,i) == 0))
                SET(count,i)=result(j).EPOCH;
                DRT(count,i)=SET(count,i)-RISE(count,i);
                count=count+1;
            end
        end
        
    end
        
    %If at the end of epoch, the satellite did not exit, set SET=999999 and
    %DRT 999999,and add 1 to count
    if (STT(epoch_s/t-1,i) == 1) && (STT(epoch_s/t,i) == 1)
        
        SET(count,i)=999999;
        DRT(count,i)=999999;
        count=count+1;
    end
    
    %If finished checking but count not increased, It means satellite is not visible to station at all,
    %then set RISE SET DRT =0
    if count==1 
        RISE(count,i)=0;
        SET(count,i)=0;
        DRT(count,i)=0;
    end
        
    count=1;
end
end
%************************************************************%
%************                                 ***************%
%************               GUI               ***************%
%************                                 ***************%
%************************************************************%
function varargout = gui(varargin)

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

% Last Modified by GUIDE v2.5 08-Jan-2017 14:12:23

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @gui_OpeningFcn, ...
                   'gui_OutputFcn',  @gui_OutputFcn, ...
                   'gui_LayoutFcn',  @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
end

% --- Executes just before gui is made visible.
function gui_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 gui (see VARARGIN)

% Choose default command line output for gui

handles.output = hObject;
handles.mode_value =1;
handles.switch_alg_value =1;
handles.mask_value=5;
handles.t_value=10;
handles.epoch_s_value=86400;
handles.plot3d_value=1;
handles.plot2df_value=1;
handles.plot2dv_value=1;
handles.sma_value=7719.637185686;
handles.ecc_value=0.00049339;
handles.inc_value=1.1526886;
handles.argp_value=3.167;
handles.raan_value=1.16148673;
handles.tran_value=5.50189;
handles.LLH_P1_value=[45 180 0];
handles.LLH_P2_value=[-45 90 0];
handles.LLH_P3_value=[-45 270 0];
handles.LLH_P4_value=[45 0 0];
set(handles.mask,'String','5');
set(handles.t,'String','10');
set(handles.epoch_s,'String','86400');
set(handles.sma,'String','7719.637185686');
set(handles.ecc,'String','0.00049339');
set(handles.inc,'String','1.1526886');
set(handles.argp,'String','3.167');
set(handles.raan,'String','1.16148673');
set(handles.tran,'String','5.50189');
set(handles.plot3d,'Value',1);
set(handles.plot2df,'Value',1);
set(handles.plot2dv,'Value',1);
set(handles.edit17,'String','45,180,0');%LLH1_P1
set(handles.edit18,'String','-45,90,0');%LLH1_P2
set(handles.edit19,'String','-45,270,0');%LLH1_P3
set(handles.edit20,'String','45,0,0');%LLH1_P4
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui wait for user response (see UIRESUME)
uiwait(handles.figure1);

end

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

end

% --- Executes on button press in Mode.
function Mode_Callback(hObject, eventdata, handles)
% hObject    handle to Mode (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 Mode
handles.mode_value=get(hObject,'Value');
guidata(hObject,handles);
end
% --- Executes on selection change in switch_alg.
function switch_alg_Callback(hObject, eventdata, handles)
% hObject    handle to switch_alg (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns switch_alg contents as cell array
%        contents{get(hObject,'Value')} returns selected item from switch_alg
handles.switch_alg_value=get(hObject,'Value');
guidata(hObject,handles);
end

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

% Hint: popupmenu 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
end
function mask_Callback(hObject, eventdata, handles)
% hObject    handle to mask (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 mask as text
%        str2double(get(hObject,'String')) returns contents of mask as a double

handles.mask_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function mask_CreateFcn(hObject, eventdata, handles)
% hObject    handle to mask (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
end

function t_Callback(hObject, eventdata, handles)
% hObject    handle to t (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 t as text
%        str2double(get(hObject,'String')) returns contents of t as a double
handles.t_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function t_CreateFcn(hObject, eventdata, handles)
% hObject    handle to t (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
end

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

guiinput(1)=1;
guiinput(2)=handles.mask_value;
guiinput(3)=handles.t_value;
guiinput(4)=handles.epoch_s_value;
guiinput(5)=handles.plot3d_value;
guiinput(6)=handles.plot2df_value;
guiinput(7)=handles.plot2dv_value;
guiinput(8)=handles.sma_value;
guiinput(9)=handles.ecc_value;
guiinput(10)=handles.inc_value;
guiinput(11)=handles.argp_value;
guiinput(12)=handles.raan_value;
guiinput(13)=handles.tran_value;
guiinput(14)=handles.switch_alg_value;
guiinput(15)=handles.LLH_P1_value(1);
guiinput(16)=handles.LLH_P1_value(2);
guiinput(17)=handles.LLH_P1_value(3);
guiinput(18)=handles.LLH_P2_value(1);
guiinput(19)=handles.LLH_P2_value(2);
guiinput(20)=handles.LLH_P2_value(3);
guiinput(21)=handles.LLH_P3_value(1);
guiinput(22)=handles.LLH_P3_value(2);
guiinput(23)=handles.LLH_P3_value(3);
guiinput(24)=handles.LLH_P4_value(1);
guiinput(25)=handles.LLH_P4_value(2);
guiinput(26)=handles.LLH_P4_value(3);

uiresume(handles.figure1);

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

handles.epoch_s_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function epoch_s_CreateFcn(hObject, eventdata, handles)
% hObject    handle to epoch_s (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
end

% --- Executes on button press in plot3d.
function plot3d_Callback(hObject, eventdata, handles)
% hObject    handle to plot3d (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 plot3d
handles.plot3d_value=get(hObject,'Value');
guidata(hObject,handles);
end
% --- Executes on button press in plot2df.
function plot2df_Callback(hObject, eventdata, handles)
% hObject    handle to plot2df (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 plot2df
handles.plot2df_value=get(hObject,'Value');
guidata(hObject,handles);
end
% --- Executes on button press in plot2dv.
function plot2dv_Callback(hObject, eventdata, handles)
% hObject    handle to plot2dv (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 plot2dv
handles.plot2dv_value=get(hObject,'Value');
guidata(hObject,handles);
end

% --- Executes when selected object is changed in Mode.
function Mode_SelectionChangedFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in Mode 
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.mode_value=get(eventdata.NewValue,'Tag')
guidata(hObject,handles);
switch handles.mode_value
    case 'freemode'

        set(handles.freemodepanel,'visible','on');
        set(handles.task1panel,'visible','off');
        set(handles.task2panel,'visible','off');
    case 'task1'
       
        set(handles.freemodepanel,'visible','off');
        set(handles.task1panel,'visible','on');
        set(handles.task2panel,'visible','off');
    case 'task2'
  
        set(handles.freemodepanel,'visible','off');
        set(handles.task1panel,'visible','off');
        set(handles.task2panel,'visible','on');
end
guidata(hObject,handles);
end

% --- 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)
end
function sma_Callback(hObject, eventdata, handles)
% hObject    handle to sma (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 sma as text
%        str2double(get(hObject,'String')) returns contents of sma as a double
handles.sma_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function sma_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sma (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
end
function ecc_Callback(hObject, eventdata, handles)
% hObject    handle to ecc (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 ecc as text
%        str2double(get(hObject,'String')) returns contents of ecc as a double
handles.ecc_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function ecc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to ecc (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
end
function inc_Callback(hObject, eventdata, handles)
% hObject    handle to inc (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 inc as text
%        str2double(get(hObject,'String')) returns contents of inc as a double
handles.inc_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function inc_CreateFcn(hObject, eventdata, handles)
% hObject    handle to inc (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
end
function raan_Callback(hObject, eventdata, handles)
% hObject    handle to raan (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 raan as text
%        str2double(get(hObject,'String')) returns contents of raan as a double
handles.raan_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function raan_CreateFcn(hObject, eventdata, handles)
% hObject    handle to raan (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
end
function argp_Callback(hObject, eventdata, handles)
% hObject    handle to argp (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 argp as text
%        str2double(get(hObject,'String')) returns contents of argp as a double
handles.argp_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function argp_CreateFcn(hObject, eventdata, handles)
% hObject    handle to argp (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
end
function tran_Callback(hObject, eventdata, handles)
% hObject    handle to tran (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 tran as text
%        str2double(get(hObject,'String')) returns contents of tran as a double
handles.tran_value=str2double(get(hObject,'String'));
guidata(hObject,handles);
end
% --- Executes during object creation, after setting all properties.
function tran_CreateFcn(hObject, eventdata, handles)
% hObject    handle to tran (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
end

% --- Executes on button press in runtask1.
function runtask1_Callback(hObject, eventdata, handles)
% hObject    handle to runtask1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global guiinput;
guiinput(1)=2; %mode selection
guiinput(2)=5; %default mask angle for task1, 5deg
guiinput(3)=10; %default time step for task1, 10s
guiinput(4)=86400; %default epoch for task1, 86400s
guiinput(5)=handles.plot3d_value;
guiinput(6)=handles.plot2df_value;
guiinput(7)=handles.plot2dv_value;
guiinput(8)=handles.sma_value;
guiinput(9)=handles.ecc_value;
guiinput(10)=handles.inc_value;
guiinput(11)=handles.argp_value;
guiinput(12)=handles.raan_value;
guiinput(13)=handles.tran_value;
guiinput(14)=handles.switch_alg_value; 

uiresume(handles.figure1);
end

% --- Executes on button press in runtask2.
function runtask2_Callback(hObject, eventdata, handles)
% hObject    handle to runtask2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
end
function edit17_Callback(hObject, eventdata, handles)
% hObject    handle to edit17 (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 edit17 as text
%        str2double(get(hObject,'String')) returns contents of edit17 as a double

handles.LLH_P1_value=str2num(get(hObject,'String'));
guidata(hObject,handles);
end

% --- Executes during object creation, after setting all properties.
function edit17_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit17 (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
end
function edit18_Callback(hObject, eventdata, handles)
% hObject    handle to edit18 (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 edit18 as text
%        str2double(get(hObject,'String')) returns contents of edit18 as a double

handles.LLH_P2_value=str2num(get(hObject,'String'));
guidata(hObject,handles);

end

% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit18 (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
end
function edit19_Callback(hObject, eventdata, handles)
% hObject    handle to edit19 (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 edit19 as text
%        str2double(get(hObject,'String')) returns contents of edit19 as a double

handles.LLH_P3_value=str2num(get(hObject,'String'));
guidata(hObject,handles);

end

% --- Executes during object creation, after setting all properties.
function edit19_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit19 (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
end
function edit20_Callback(hObject, eventdata, handles)
% hObject    handle to edit20 (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 edit20 as text
%        str2double(get(hObject,'String')) returns contents of edit20 as a double

handles.LLH_P4_value=str2num(get(hObject,'String'));
guidata(hObject,handles);

end

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

end
% --- Creates and returns a handle to the GUI figure. 
function h1 = gui_LayoutFcn(policy)
% policy - create a new figure or use a singleton. 'new' or 'reuse'.

persistent hsingleton;
if strcmpi(policy, 'reuse') & ishandle(hsingleton)
    h1 = hsingleton;
    return;
end

appdata = [];
appdata.GUIDEOptions = struct(...
    'active_h', [], ...
    'taginfo', struct(...
    'figure', 2, ...
    'text', 33, ...
    'radiobutton', 5, ...
    'uibuttongroup', 6, ...
    'listbox', 3, ...
    'popupmenu', 5, ...
    'edit', 21, ...
    'pushbutton', 5, ...
    'checkbox', 11, ...
    'axes', 2, ...
    'uipanel', 10, ...
    'slider', 2), ...
    'override', 0, ...
    'release', [], ...
    'resize', 'none', ...
    'accessibility', 'callback', ...
    'mfile', 1, ...
    'callbacks', 1, ...
    'singleton', 1, ...
    'syscolorfig', 1, ...
    'blocking', 0, ...
    'lastSavedFile', 'C:UsersYangDesktopgui.m', ...
    'lastFilename', 'C:UsersYangDesktopDocCEGE301M Space Systemscoursework2gui.fig');
appdata.lastValidTag = 'figure1';
appdata.GUIDELayoutEditor = [];
appdata.initTags = struct(...
    'handle', [], ...
    'tag', 'figure1');

h1 = figure(...
'PaperUnits','inches',...
'Units','characters',...
'Position',[135.8 32.7963800904977 131.714285714286 51.5882352941176],...
'Visible',get(0,'defaultfigureVisible'),...
'Color',get(0,'defaultfigureColor'),...
'CloseRequestFcn',get(0,'defaultfigureCloseRequestFcn'),...
'CurrentAxesMode','manual',...
'CurrentObjectMode','manual',...
'CurrentPointMode','manual',...
'SelectionTypeMode','manual',...
'ResizeFcn',blanks(0),...
'IntegerHandle','off',...
'NextPlot',get(0,'defaultfigureNextPlot'),...
'Alphamap',get(0,'defaultfigureAlphamap'),...
'WindowButtonDownFcn',blanks(0),...
'WindowButtonUpFcn',blanks(0),...
'WindowButtonMotionFcn',blanks(0),...
'WindowScrollWheelFcn',blanks(0),...
'WindowKeyPressFcn',blanks(0),...
'WindowKeyReleaseFcn',blanks(0),...
'MenuBar','none',...
'ToolBar',get(0,'defaultfigureToolBar'),...
'Pointer',get(0,'defaultfigurePointer'),...
'PointerShapeHotSpot',get(0,'defaultfigurePointerShapeHotSpot'),...
'Name','gui',...
'NumberTitle','off',...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','figure1',...
'UserData',[],...
'WindowStyle',get(0,'defaultfigureWindowStyle'),...
'DockControls',get(0,'defaultfigureDockControls'),...
'Resize','off',...
'PaperPosition',get(0,'defaultfigurePaperPosition'),...
'PaperSize',[8.5 11],...
'PaperType','usletter',...
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'PaperOrientation',get(0,'defaultfigurePaperOrientation'),...
'ScreenPixelsPerInchMode','manual',...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility','callback');

appdata = [];
appdata.lastValidTag = 'uipanel8';

h2 = uipanel(...
'Parent',h1,...
'FontUnits',get(0,'defaultuipanelFontUnits'),...
'Units','characters',...
'Title','Task 1',...
'Tag','uipanel8',...
'Position',[4.14285714285714 11.5882352941176 118.857142857143 11.3529411764706],...
'FontSize',10,...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'uipanel7';

h3 = uipanel(...
'Parent',h1,...
'FontUnits',get(0,'defaultuipanelFontUnits'),...
'Units','characters',...
'Title','Free Mode Control Panel',...
'Tag','uipanel7',...
'Position',[4.42857142857143 23.4117647058824 122.142857142857 25.1764705882353],...
'FontSize',10,...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text2';

h4 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'String','Satellite Propogation Prediction Software',...
'Style','text',...
'Position',[31.8571428571429 48.5882352941176 63.2857142857143 2.11764705882353],...
'Children',[],...
'Tag','text2',...
'FontSize',14,...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text4';

h5 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Mask Angle',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[7.71428571428571 40.5294117647059 12.2857142857143 1.1764705882353],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text4',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'text5';

h6 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Time Step',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[7.71428571428571 36.1764705882353 10.7142857142857 1.1764705882353],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text5',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'mask';

h7 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','5',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[7.57142857142857 38.7647058823529 7.28571428571429 1.70588235294117],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('mask_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('mask_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','mask',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 't';

h8 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','10',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[7.85714285714286 34.3529411764706 7.28571428571429 1.70588235294117],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('t_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('t_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','t',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'text6';

h9 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Epoch (s)',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[7.85714285714286 31.9411764705882 9.71428571428571 1.17647058823529],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text6',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'epoch_s';

h10 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','86400',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[7.71428571428571 29.5882352941176 7.28571428571429 1.70588235294118],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('epoch_s_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('epoch_s_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','epoch_s',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'switch_alg';

h11 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String',{  'Keplerian Propogation'; 'RK4'; 'RK4-J2' },...
'Style','popupmenu',...
'Value',1,...
'Position',[7.14285714285714 43.2941176470588 25 1.47058823529412],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('switch_alg_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('switch_alg_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','switch_alg',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'text3';

h12 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Prediction Algorithm',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[7 45.0588235294118 22.5714285714286 1.1764705882353],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text3',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'run';

h13 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Run',...
'Style',get(0,'defaultuicontrolStyle'),...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[104.142857142857 29.5882352941176 11.8571428571429 2.70588235294117],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',@(hObject,eventdata)gui('run_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','run',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',10,...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'text16';

h14 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Semi Major Axis (km)',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 45 18.4285714285714 1.05882352941177],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text16',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'text17';

h15 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Eccentricity',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 41.4705882352941 18.4285714285714 1.05882352941177],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text17',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'raan_text';

h16 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','RAAN (rad)',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.5714285714286 31 18.4285714285714 1.05882352941177],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','raan_text',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'tran_text';

h17 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','True Anomaly (rad)',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 27.3529411764706 18.4285714285714 1.05882352941176],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','tran_text',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'argp_text';

h18 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Argument  of perigee (rad)',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.5714285714286 34.3529411764706 22.4285714285714 1.05882352941177],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','argp_text',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'text21';

h19 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','Inclination (rad)',...
'Style','text',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 37.9411764705882 18.4285714285714 1.05882352941177],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',blanks(0),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text21',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'sma';

h20 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','7719.637185686',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.2857142857143 43.1764705882353 15.1428571428571 1.58823529411765],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('sma_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('sma_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','sma',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'ecc';

h21 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','0.00049339',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 39.7058823529412 11.4285714285714 1.58823529411765],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('ecc_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('ecc_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','ecc',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'inc';

h22 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','1.1526886',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 36 11.4285714285714 1.58823529411765],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('inc_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('inc_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','inc',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'raan';

h23 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','1.16148673',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 28.8823529411765 11.4285714285714 1.58823529411765],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('raan_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('raan_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','raan',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'argp';

h24 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','3.167',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 32.6470588235294 11.4285714285714 1.58823529411765],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('argp_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('argp_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','argp',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'tran';

h25 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','5.50189',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[34.4285714285714 25.6470588235294 11.4285714285714 1.58823529411765],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('tran_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('tran_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','tran',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'plot2dv';

h26 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'String','2D Path visible to stations',...
'Style','checkbox',...
'Value',1,...
'Position',[95.8571428571428 37.4705882352941 27.2857142857143 1.76470588235294],...
'Callback',@(hObject,eventdata)gui('plot2dv_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','plot2dv',...
'KeyPressFcn',blanks(0));

appdata = [];
appdata.lastValidTag = 'text24';

h27 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'String',{  'Click the button to run Task 1.'; 'Task 1 uses Keplerian Propogation and RK4 Algorithm to predict satellite''s state.'; 'Then the difference will be plotted.'; 'A net work of four ground stations will be found'; 'The path visible to stations will be plotted'; 'Parameters used: time step 10s, mask angle 5 deg, epoch 86400 (24hrs).' },...
'Style','text',...
'Position',[7 14.1764705882353 70 6.76470588235294],...
'Children',[],...
'Tag','text24',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'uipanel9';

h28 = uipanel(...
'Parent',h1,...
'FontUnits',get(0,'defaultuipanelFontUnits'),...
'Units','characters',...
'Title','Task 2',...
'Tag','uipanel9',...
'Position',[3.85714285714286 2.29411764705882 119.571428571429 8.82352941176471],...
'FontSize',10,...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'text25';

h29 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'String','task2discrip',...
'Style','text',...
'Position',[9 5.29411764705882 33.7142857142857 2.88235294117647],...
'Children',[],...
'Tag','text25',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'runtask2';

h30 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'String','Run',...
'Style',get(0,'defaultuicontrolStyle'),...
'Position',[95.2857142857143 5.52941176470588 11.7142857142857 3],...
'Callback',@(hObject,eventdata)gui('runtask2_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'Tag','runtask2',...
'FontSize',10,...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'groundstation';

h31 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'String','Station 1',...
'Style','text',...
'Position',[60.5714285714286 43.5294117647059 20 1.29411764705883],...
'Children',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'Tag','groundstation');

appdata = [];
appdata.lastValidTag = 'edit17';

h32 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','0,0,0',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[60.2857142857143 41.8823529411765 30 1.52941176470588],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('edit17_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('edit17_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','edit17',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'edit18';

h33 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','0,0,0',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[60.2857142857143 38.2352941176471 30 1.52941176470588],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('edit18_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('edit18_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','edit18',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'edit19';

h34 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','0,0,0',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[60.2857142857143 34.5882352941176 30 1.52941176470588],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('edit19_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('edit19_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','edit19',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'edit20';

h35 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','0,0,0',...
'Style','edit',...
'Value',get(0,'defaultuicontrolValue'),...
'Position',[60.2857142857143 30.9411764705882 30 1.52941176470588],...
'BackgroundColor',[1 1 1],...
'Callback',@(hObject,eventdata)gui('edit20_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, @(hObject,eventdata)gui('edit20_CreateFcn',hObject,eventdata,guidata(hObject)), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','edit20',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'text28';

h36 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'String','Station 2',...
'Style','text',...
'Position',[60.5714285714286 39.8823529411765 20 1.29411764705883],...
'Children',[],...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text28');

appdata = [];
appdata.lastValidTag = 'text29';

h37 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'String','Station 3',...
'Style','text',...
'Position',[60.5714285714286 36.2352941176471 20 1.29411764705883],...
'Children',[],...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text29');

appdata = [];
appdata.lastValidTag = 'text30';

h38 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'String','Station 4',...
'Style','text',...
'Position',[60.5714285714286 32.5882352941176 20 1.29411764705883],...
'Children',[],...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text30');

appdata = [];
appdata.lastValidTag = 'text32';

h39 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'String','Ground Station Network',...
'Style','text',...
'Position',[60.5714285714286 45.3529411764706 25.7142857142857 1.29411764705883],...
'Children',[],...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','text32',...
'FontSize',10);

appdata = [];
appdata.lastValidTag = 'plot';

h40 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment','left',...
'String','Plot Options',...
'Style','text',...
'Position',[96.8571428571428 44.6470588235294 23.4285714285714 1.64705882352941],...
'Children',[],...
'Tag','plot',...
'FontSize',10,...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'runtask1';

h41 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'String','Run',...
'Style',get(0,'defaultuicontrolStyle'),...
'Position',[101 16.2941176470588 13.1428571428571 2.88235294117647],...
'Callback',@(hObject,eventdata)gui('runtask1_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'Tag','runtask1',...
'FontSize',10,...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );

appdata = [];
appdata.lastValidTag = 'plot2df';

h42 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','2D Full Path',...
'Style','checkbox',...
'Value',1,...
'Position',[95.8571428571428 39.6470588235294 23.1428571428571 1.76470588235294],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',@(hObject,eventdata)gui('plot2df_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','plot2df',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));

appdata = [];
appdata.lastValidTag = 'plot3d';

h43 = uicontrol(...
'Parent',h1,...
'FontUnits',get(0,'defaultuicontrolFontUnits'),...
'Units','characters',...
'HorizontalAlignment',get(0,'defaultuicontrolHorizontalAlignment'),...
'ListboxTop',get(0,'defaultuicontrolListboxTop'),...
'Max',get(0,'defaultuicontrolMax'),...
'Min',get(0,'defaultuicontrolMin'),...
'SliderStep',get(0,'defaultuicontrolSliderStep'),...
'String','3D Plot',...
'Style','checkbox',...
'Value',1,...
'Position',[95.8571428571428 41.8235294117647 23.1428571428571 1.76470588235294],...
'BackgroundColor',get(0,'defaultuicontrolBackgroundColor'),...
'Callback',@(hObject,eventdata)gui('plot3d_Callback',hObject,eventdata,guidata(hObject)),...
'Children',[],...
'ForegroundColor',get(0,'defaultuicontrolForegroundColor'),...
'Enable',get(0,'defaultuicontrolEnable'),...
'TooltipString',blanks(0),...
'Visible',get(0,'defaultuicontrolVisible'),...
'ButtonDownFcn',blanks(0),...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} ,...
'DeleteFcn',blanks(0),...
'Tag','plot3d',...
'UserData',[],...
'KeyPressFcn',blanks(0),...
'KeyReleaseFcn',blanks(0),...
'HandleVisibility',get(0,'defaultuicontrolHandleVisibility'),...
'FontSize',get(0,'defaultuicontrolFontSize'),...
'FontName',get(0,'defaultuicontrolFontName'),...
'FontAngle',get(0,'defaultuicontrolFontAngle'),...
'FontWeight',get(0,'defaultuicontrolFontWeight'));
hsingleton = h1;

end
% --- Set application data first then calling the CreateFcn. 
function local_CreateFcn(hObject, eventdata, createfcn, appdata)

if ~isempty(appdata)
   names = fieldnames(appdata);
   for i=1:length(names)
       name = char(names(i));
       setappdata(hObject, name, getfield(appdata,name));
   end
end

if ~isempty(createfcn)
   if isa(createfcn,'function_handle')
       createfcn(hObject, eventdata);
   else
       eval(createfcn);
   end
end
end

% --- Handles default GUIDE GUI creation and callback dispatch
function varargout = gui_mainfcn(gui_State, varargin)

gui_StateFields =  {'gui_Name'
    'gui_Singleton'
    'gui_OpeningFcn'
    'gui_OutputFcn'
    'gui_LayoutFcn'
    'gui_Callback'};
gui_Mfile = '';
for i=1:length(gui_StateFields)
    if ~isfield(gui_State, gui_StateFields{i})
        error(message('MATLAB:guide:StateFieldNotFound', gui_StateFields{ i }, gui_Mfile));
    elseif isequal(gui_StateFields{i}, 'gui_Name')
        gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
    end
end

numargin = length(varargin);

if numargin == 0
    % GUI
    % create the GUI only if we are not in the process of loading it
    % already
    gui_Create = true;
elseif local_isInvokeActiveXCallback(gui_State, varargin{:})
    % GUI(ACTIVEX,...)
    vin{1} = gui_State.gui_Name;
    vin{2} = [get(varargin{1}.Peer, 'Tag'), '_', varargin{end}];
    vin{3} = varargin{1};
    vin{4} = varargin{end-1};
    vin{5} = guidata(varargin{1}.Peer);
    feval(vin{:});
    return;
elseif local_isInvokeHGCallback(gui_State, varargin{:})
    % GUI('CALLBACK',hObject,eventData,handles,...)
    gui_Create = false;
else
    % GUI(...)
    % create the GUI and hand varargin to the openingfcn
    gui_Create = true;
end

if ~gui_Create
    % In design time, we need to mark all components possibly created in
    % the coming callback evaluation as non-serializable. This way, they
    % will not be brought into GUIDE and not be saved in the figure file
    % when running/saving the GUI from GUIDE.
    designEval = false;
    if (numargin>1 && ishghandle(varargin{2}))
        fig = varargin{2};
        while ~isempty(fig) && ~ishghandle(fig,'figure')
            fig = get(fig,'parent');
        end
        
        designEval = isappdata(0,'CreatingGUIDEFigure') || (isscalar(fig)&&isprop(fig,'GUIDEFigure'));
    end
        
    if designEval
        beforeChildren = findall(fig);
    end
    
    % evaluate the callback now
    varargin{1} = gui_State.gui_Callback;
    if nargout
        [varargout{1:nargout}] = feval(varargin{:});
    else       
        feval(varargin{:});
    end
    
    % Set serializable of objects created in the above callback to off in
    % design time. Need to check whether figure handle is still valid in
    % case the figure is deleted during the callback dispatching.
    if designEval && ishghandle(fig)
        set(setdiff(findall(fig),beforeChildren), 'Serializable','off');
    end
else
    if gui_State.gui_Singleton
        gui_SingletonOpt = 'reuse';
    else
        gui_SingletonOpt = 'new';
    end

    % Check user passing 'visible' P/V pair first so that its value can be
    % used by oepnfig to prevent flickering
    gui_Visible = 'auto';
    gui_VisibleInput = '';
    for index=1:2:length(varargin)
        if length(varargin) == index || ~ischar(varargin{index})
            break;
        end

        % Recognize 'visible' P/V pair
        len1 = min(length('visible'),length(varargin{index}));
        len2 = min(length('off'),length(varargin{index+1}));
        if ischar(varargin{index+1}) && strncmpi(varargin{index},'visible',len1) && len2 > 1
            if strncmpi(varargin{index+1},'off',len2)
                gui_Visible = 'invisible';
                gui_VisibleInput = 'off';
            elseif strncmpi(varargin{index+1},'on',len2)
                gui_Visible = 'visible';
                gui_VisibleInput = 'on';
            end
        end
    end
    
    % Open fig file with stored settings.  Note: This executes all component
    % specific CreateFunctions with an empty HANDLES structure.

    
    % Do feval on layout code in m-file if it exists
    gui_Exported = ~isempty(gui_State.gui_LayoutFcn);
    % this application data is used to indicate the running mode of a GUIDE
    % GUI to distinguish it from the design mode of the GUI in GUIDE. it is
    % only used by actxproxy at this time.   
    setappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]),1);
    if gui_Exported
        gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt);

        % make figure invisible here so that the visibility of figure is
        % consistent in OpeningFcn in the exported GUI case
        if isempty(gui_VisibleInput)
            gui_VisibleInput = get(gui_hFigure,'Visible');
        end
        set(gui_hFigure,'Visible','off')

        % openfig (called by local_openfig below) does this for guis without
        % the LayoutFcn. Be sure to do it here so guis show up on screen.
        movegui(gui_hFigure,'onscreen');
    else
        gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
        % If the figure has InGUIInitialization it was not completely created
        % on the last pass.  Delete this handle and try again.
        if isappdata(gui_hFigure, 'InGUIInitialization')
            delete(gui_hFigure);
            gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
        end
    end
    if isappdata(0, genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]))
        rmappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]));
    end

    % Set flag to indicate starting GUI initialization
    setappdata(gui_hFigure,'InGUIInitialization',1);

    % Fetch GUIDE Application options
    gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
    % Singleton setting in the GUI MATLAB code file takes priority if different
    gui_Options.singleton = gui_State.gui_Singleton;

    if ~isappdata(gui_hFigure,'GUIOnScreen')
        % Adjust background color
        if gui_Options.syscolorfig
            set(gui_hFigure,'Color', get(0,'DefaultUicontrolBackgroundColor'));
        end

        % Generate HANDLES structure and store with GUIDATA. If there is
        % user set GUI data already, keep that also.
        data = guidata(gui_hFigure);
        handles = guihandles(gui_hFigure);
        if ~isempty(handles)
            if isempty(data)
                data = handles;
            else
                names = fieldnames(handles);
                for k=1:length(names)
                    data.(char(names(k)))=handles.(char(names(k)));
                end
            end
        end
        guidata(gui_hFigure, data);
    end

    % Apply input P/V pairs other than 'visible'
    for index=1:2:length(varargin)
        if length(varargin) == index || ~ischar(varargin{index})
            break;
        end

        len1 = min(length('visible'),length(varargin{index}));
        if ~strncmpi(varargin{index},'visible',len1)
            try set(gui_hFigure, varargin{index}, varargin{index+1}), catch break, end
        end
    end

    % If handle visibility is set to 'callback', turn it on until finished
    % with OpeningFcn
    gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
    if strcmp(gui_HandleVisibility, 'callback')
        set(gui_hFigure,'HandleVisibility', 'on');
    end

    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

    if isscalar(gui_hFigure) && ishghandle(gui_hFigure)
        % Handle the default callbacks of predefined toolbar tools in this
        % GUI, if any
        guidemfile('restoreToolbarToolPredefinedCallback',gui_hFigure); 
        
        % Update handle visibility
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);

        % Call openfig again to pick up the saved visibility or apply the
        % one passed in from the P/V pairs
        if ~gui_Exported
            gui_hFigure = local_openfig(gui_State.gui_Name, 'reuse',gui_Visible);
        elseif ~isempty(gui_VisibleInput)
            set(gui_hFigure,'Visible',gui_VisibleInput);
        end
        if strcmpi(get(gui_hFigure, 'Visible'), 'on')
            figure(gui_hFigure);
            
            if gui_Options.singleton
                setappdata(gui_hFigure,'GUIOnScreen', 1);
            end
        end

        % Done with GUI initialization
        if isappdata(gui_hFigure,'InGUIInitialization')
            rmappdata(gui_hFigure,'InGUIInitialization');
        end

        % If handle visibility is set to 'callback', turn it on until
        % finished with OutputFcn
        gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
        if strcmp(gui_HandleVisibility, 'callback')
            set(gui_hFigure,'HandleVisibility', 'on');
        end
        gui_Handles = guidata(gui_hFigure);
    else
        gui_Handles = [];
    end

    if nargout
        [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    else
        feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    end

    if isscalar(gui_hFigure) && ishghandle(gui_hFigure)
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
    end
end
end
function gui_hFigure = local_openfig(name, singleton, visible)

% openfig with three arguments was new from R13. Try to call that first, if
% failed, try the old openfig.
if nargin('openfig') == 2
    % OPENFIG did not accept 3rd input argument until R13,
    % toggle default figure visible to prevent the figure
    % from showing up too soon.
    gui_OldDefaultVisible = get(0,'defaultFigureVisible');
    set(0,'defaultFigureVisible','off');
    gui_hFigure = matlab.hg.internal.openfigLegacy(name, singleton);
    set(0,'defaultFigureVisible',gui_OldDefaultVisible);
else
    % Call version of openfig that accepts 'auto' option"
    gui_hFigure = matlab.hg.internal.openfigLegacy(name, singleton, visible);  
%     %workaround for CreateFcn not called to create ActiveX
%         peers=findobj(findall(allchild(gui_hFigure)),'type','uicontrol','style','text');    
%         for i=1:length(peers)
%             if isappdata(peers(i),'Control')
%                 actxproxy(peers(i));
%             end            
%         end
end
end
function result = local_isInvokeActiveXCallback(gui_State, varargin)

try
    result = ispc && iscom(varargin{1}) ...
             && isequal(varargin{1},gcbo);
catch
    result = false;
end
end
function result = local_isInvokeHGCallback(gui_State, varargin)

try
    fhandle = functions(gui_State.gui_Callback);
    result = ~isempty(findstr(gui_State.gui_Name,fhandle.file)) || ...
             (ischar(varargin{1}) ...
             && isequal(ishghandle(varargin{2}), 1) ...
             && (~isempty(strfind(varargin{1},[get(varargin{2}, 'Tag'), '_'])) || ...
                ~isempty(strfind(varargin{1}, '_CreateFcn'))) );
catch
    result = false;
end
end

Customer Feedback

"Thanks for explanations after the assignment was already completed... Emily is such a nice tutor! "

Order #13073

Find Us On

soc fb soc insta


Paypal supported