Need to modify function handle output when a function is within the function handle

The funciton "rockdynamicstage" outputs a matrix 4 by x, where x is somthing around 300( varies).
The funciton "rockdynamicstage" is within the funciton handle "sim" with an input of gama0. (PayMass,Masstages,Massfrac,Thstage,IspStage,ChangeTstage) are parameters that are set earlier in the code.
sim= @(gama0) rockdynamicstage(gama0,PayMass,Masstages,Massfrac,Thstage,IspStage,ChangeTstage);
I need the "sim" to output the last element in the 4th row of the "rockdynamicstage". So that I get the last element in the 4th row in "rockdynamicstage" for a range of gama0s.
How would I output it. 3. The attempt at a solution I tried doing sim= @(gama0) rockdynamicstage(gama0,PayMass,Masstages,Massfrac,Thstage,IspStage,ChangeTstage)(4,end);
This essentially is the outline but myrocketsim is rockdynamicstage. And the bisection method is used to find the zero

 採用された回答

James Tursa
James Tursa 2017 年 12 月 7 日
E.g., you could use another function handle to pick off the element you wanted.
sim4end = @(x)x(4,end)
Then your result would be
sim4end(sim(gamma0))

3 件のコメント

Carter Hughes
Carter Hughes 2017 年 12 月 7 日
would this work still for a range of gamma0?
James Tursa
James Tursa 2017 年 12 月 7 日
編集済み: James Tursa 2017 年 12 月 7 日
The only restriction on using sim4end is that the indexing (4,end) makes sense for whatever gets returned from sim(gamma0). So, what exactly gets returned from sim(gamma0) when gamma0 is a range of values?
Carter Hughes
Carter Hughes 2017 年 12 月 7 日
makes sense, Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics and Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by