So I have a series of functions that all depend on an initial function. For example, I want to design a helicopter. I have a program that gives an initial weight estimate. This weight estimate is used by other programs to figure out how big my wings, transmission, and rotors are going to be. I, then, have another program that calculates a new weight based on the size of these geometric properties. I would like this value from this new output to be the next input into the geometric sizing programs that originally took in the value of my initial weight estimation program.

 채택된 답변

the cyclist
the cyclist 2019년 10월 28일
편집: the cyclist 2019년 10월 28일

1 개 추천

Conceptually, something like this?
weightEstimate = initialWeightEstimate
while <some condition>
geometryEstimate = geometricEstimatorFunction(weightEstimate,<other inputs to geometry estimator>)
weightEstimate = weightEstimatorFunction(geometryEstimate,<otherinputs to weight estimator>)
end

댓글 수: 4

Albert Garcia
Albert Garcia 2019년 10월 28일
Yeah, this seems right. So I would need my weightEstimatorFunction to be inside the initialWeightEstimate function, and I guess if I run the initialWeightEstimate function and it detects that the geometricEstimatorFunction function has been run already, initialWeightEstimate would output the value from weightEstimatorFunction. How would I end up getting my initialWeightEstimate function to figure out that I already had geometricEstimatorFunction be run? Is there a way for me to get a "true"/"false" value from checking to see if a function has been run?
Would the best solution be to have my initialWeightEstimate function have a loop like below?
weightEstimate = initialWeightEstimate
int = 0;
for int < 10
if int<1
weightEstimate = initialWeightEstimate;
else
weightEstimate = weightEstimatorFunction(geometryEstimate);
end
geometryEstimate = geometricEstimatorFunction(weightEstimate);
int = int + 1;
end
the cyclist
the cyclist 2019년 10월 28일
Yes, this would be a good conceptual solution, if you know the number of iterations you want.
Regarding your "checking to see if a function has been been run" question ... MATLAB will simply run the lines of code in strict order, waiting for the prior one to finish before starting the next one. So, there is no need to check if a prior line has been completed.
Albert Garcia
Albert Garcia 2019년 10월 28일
Cool. Thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2019년 10월 28일

댓글:

2019년 10월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by