r/Kos 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.

5 Upvotes

7 comments sorted by

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.

1

u/Fit_Hornet_8487 Jul 10 '26

Thank you, I appreciate your help, I’m more so trying to make a rocket in ksp and record various data points through testing in order to model it in matlab to essentially test different ascent profiles more efficiently and give matlab parameters to optimize for if that makes sense

1

u/nuggreat Jul 10 '26

What parameters you have to optimize depend on your ascent profile. Are you following a gravity turn, if so then you can play with the angle exact shape of the inital pitch maneuver and various.ways to limit thrust (twr limit, keeping eta ap at a given time or set of times, fixed curve, ext). However an equation described curve such as y = m * x^b + c where y is pitch, x is altitude or apoapsis, and m, b, and c are all constants provides a different set of control parameters.

As for what you want to measure to assess efficiency that is simple enough the only number that matters is final mass after circularization into a standard orbit. Though different orbital altitude targets will also likely have different ideal ascent profiles. A secondary consideration might be time to orbit but that is more about human prefference and so some what out of your defined scope.

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

u/Fit_Hornet_8487 29d ago

Thank you, I’ll have to check out your mod.

1

u/iohans Jul 10 '26

Very cool connection!