Creation of a loop code
조회 수: 2 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
Jakob B. Nielsen
2020년 2월 3일
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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!