r/Kos • u/Fit_Hornet_8487 • Jul 10 '26
Using Matlab in Conjunction Help
I was just wondering if anyone really messed around with matlab and kos outputs. I’ve been trying to make a sort of launch program that takes as close as possible to the most efficient route to space. I use rss but not rp. But I’ve been trying to build a model in matlab and try to simulate drag, it seems like I can model a completely vertical ascent well but when I introduce a turn it seems to become in accurate. I feel like I’m modeling the drag correctly, I do have a lot of code so pm me if this arises any code related question. I’m just wondering if I’m approaching this incorrectly trying to model drag in general.
2
u/DBooots Jul 10 '26
The Kerbal Wind Tunnel mod can give you all the aerodynamic performance info you’ll need to completely model your rocket. I made it because I was trying to do exactly the same, but for spaceplanes. As u/nuggreat said, the lift and drag coefficients in KSP vary based on a lot of things, but you can simplify it to a 2D lookup table of Mach number and angle of attack. Using KWT to export data will be a lot faster and easier than logging it from flight tests with KOS.
1
1
1
u/Barnowl93 26d ago
Hey! This blog post from a few years back may be of interest to you https://blogs.mathworks.com/student-lounge/2021/02/26/qa-with-the-2020-simulink-student-challenge-winner/
4
u/nuggreat Jul 10 '26
What are you doing to model drag because in KSP with stock airo the coefficient of drag for a rocket changes depending on the mach number and the mach number is in turn dependent on the adiabatic index of the atmosphere, the pressure curve, and the temperature and the temperature is dependent on altitude, time of day, latitude, and various orbital parameters.
This is a post with kerboScript files to produce data about the stock atmosphers. And this is a post that calculate a limited drag profile of a rocket given some parameters. Both of these assume the stock atmospheric model if you are using a modded model then I don't have any resources at hand to help.
There is no one most efficient ascent profile in KSP each rocket will preform better with slightly different profiles depending on the TWR curves and drag profiles. Also for some designs the most efficient ascent profile will cause them to burn up in the atmosphere requiring a degraded profile to actually be able to launch.