Creation of a loop code

2 Ansichten (letzte 30 Tage)
Adam Francki
Adam Francki am 1 Feb. 2020
Hi, I’ve finished creating a function that outputs a specific impulse for a given mass ratio of 3 mixtures of a propellant. For example the function is:
[x_1,x_2,x_3,isp]=MixRatio(x_1,x_2,x_3)
Where the inputs are: x_1=% of mixture 1 x_2=% of mixture 2 x_3=% of mixture 3
Outputs: x values as per inputs isp=calculated specific impulse based on the input mixture ratios.
Ideally I would like to output a column array in the form as per the function output ([x_1,x_2,x_3,isp]). But I want to run it through a loop function where I can calculate an isp for every ratio of the 3 mixtures (1-100%). So when x1=5, sum of x2 and 3 must equal 90, and so on for all the combinations of mixtures in 1% increments.
The idea is to find all the combinations of the % ratios of mixtures that yield the same isp and then creat a ternary contour plot. Any help would be great as I’m struggling on this!

Antworten (1)

Jakob B. Nielsen
Jakob B. Nielsen am 3 Feb. 2020
This partition function might help. Call plist=partitions(100,1:100,[],3); and you will get a 833x100 matrix where the sum of the index of every row times its value is 100. Should be a 'simple' job to convert that to x1, x2 and x3 values ;) (if you are stuck I like to "manually" do 1, 2 or even 3 repetitions and then identify what it is you do - and convert that to loop language).
The "challenge" is that there are 833 combination possibilities, and the function does not repeat combinations (so if 33%, 33% and 34% has occured, then 34%, 33% and 33% will not occur), so you will have to write some logic, probably... but I think this is a great place to start in regards to the possible combinations conundrum!

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by