PDF document and a MATLAB script called flyby_matlab that can be used to design and optimize interplanetary trajectories that include a single gravity assist maneuver. The user specifies the launch, flyby and destination planets, and the desired flyby altitude. The algorithm also requires initial guesses for the launch, flyby and arrival calendar dates. This script searches for a patched-conic gravity-assist trajectory that satisfies the flyby mission constraints (V-infinity matching and user-defined flyby altitude) and minimizes the launch, arrival or total impulsive delta-v for the mission. The type of delta-v optimization is specified by the user.
David Eagle (2020). Gravity-assist Trajectory Design and Analysis (https://www.mathworks.com/matlabcentral/fileexchange/39462-gravity-assist-trajectory-design-and-analysis), MATLAB Central File Exchange. Retrieved .
Error message is still displayed after following the steps. Is it a licence issue? I was only able to obtain the Student and not the commercial license.
Recommended setup (1) create a sub-directory named flyby_matlab (for example) (2) copy all files from flyby_matlab.zip to this directory (3) copy all SNOPT files and the DE421 ephemeris file to this sub-directory (4) log in to this sub-directory from within MATLAB (5) run the script in the flyby_matlab sub-directory
Hello, I followed the SNOPT steps by Mick Smith, and the following error occurred:
"Error using snoptmex
Error reading license file
Error in snopt (line 294)
xstate,Fstate,itn,mjritn] = snoptmex(solveopt, ...
Error in t1diet (line 12)
[x,F,INFO,xmul,Fmul,xstate,Fstate,output]= snopt( x, xlow,
xupp, xmul, xstate, ...
Error in runNPexamples (line 10)
[x,xmul,F,Fmul,info] = t1diet;"
Any idea on how to fix this issue?
For everyone below that was having trouble getting this to work:
1. Go here to request a license for SNOPT (snopt7.lic) and to get the snoptmex file: https://ccom.ucsd.edu/~optimizers/downloads/
2. Download the *.m files for snopt: https://github.com/snopt/snopt-matlab/releases
Make sure you get the latest version.
3. Move the snopt7.lic and snoptmex file into the snopt-matlab-2.5.0 file you downloaded in part 2
4. On Matlab, go to Home - > Environment - > Set Path
5. Click 'Add with subfolders' and then click the snopt-matlab-2.5.0
6. In the matlab terminal type setenv('SNOPT_LICENSE','C:\Users\User\Documents\MATLAB\snopt-matlab-2.5.0\snopt7.lic')
hit enter and then type runNPexamples to test the NLP solver. If no errors occur then it's working.
For JPL ephemeris:
1. Go to this website: https://cdeaglejr.wordpress.com
2. Find 'Ephemeris Binary Files' and click on the dropbox link
3. Download de421.bin
4. Move de421.bin to the flyby_matlab file you downloaded
Getting the de421.bin file will solve the "userfun should return 1 or 2 arguments" error.
can you give me instructions for using SNOP with Gravity-assist Trajectory Design and Analysis. thank you.
Okay it's great to be honest. I have a small problem though and it's kind of a pain. I am unable to run the snopt function. When I try to run it I get the following error:
Error using snopt (line 189)
userfun should return 1 or 2 arguments
Please help me out. This is really a pain and is not letting me go forward.
I think there is miss-typing in " fbyfunc"
In this code, the equation to obtain the turn angle is typed as below
phi1 = 0.5 * pi + 0.5 * asin(v1crossv2m / (vinfm_in * vinfm_out));
but I think it should be fixed like this
phi1 = 0.5 * pi - 0.5 * asin(v1crossv2m / (vinfm_in * vinfm_out));
can you check for me ?
When compiling the program I get the following error, can you help me please?
error: userfun should return 1 or 2 arguments
error: called from
snopt at line 188 column 5
flyby_matlab at line 356 column 23
Undefined function or variable 'snopt'.
Error in flyby_matlab (line 356)
[x, f, inform, xmul, fmul] = snopt(xg, xlwr, xupr,
xmul, xstate, ...
Where is the snopt function defined?
Script is now "data file driven". Added asteroid or comet as arrival body. Updated PDF document and added several new example missions.
MATLAB source code updates (new keywords, etc.)
Fixed bug in code that calculated the heliocentric orbital elements and state vector of the departure planet. (emu replaced with smu in the calling argument).
Binary Ephemeris Files
Bug fixes. Added three-dimensional graphics for the flyby trajectory. Updated PDF document.
Added main script (flyby_matlab_64bit.m) that uses the March 17, 2014 version of SNOPT.
MICE version included in flyby_mice.zip archive.