How Can I store results from Variable step solver(ODE15s) to a Pre-initialized variable

1 回表示 (過去 30 日間)
Hello All, I have been working on a problem which using ODE15s solver and anonymous function . I have used Coder.extrinsic(myfunction) in my MATLAB code in order to avoid issues while codegen. So I need to pre-Initialize a variable to store results from myfunction. My Coder.extrinsic(myfunction) has following code.
[T,Y] = ode15s(@(t,y) fn_diffeq(t,y,a,b,b,d,e,f,g,h,i,j), [0,time],k);
The size of Y will change according to input conditions to ODE15s Solver. it might be 100x40 for first iteration, 200x40 for second iteration and 10x40 for third iteration and etc.
I am looking for a way to Pre-initialize a variable to store this result vector.
Can Someone please help me to figure out a way to implement this problem.
Thanks in advance. Easwar

採用された回答

Easwar Kumar Yarrabikki
Easwar Kumar Yarrabikki 2017 年 1 月 20 日
編集済み: Easwar Kumar Yarrabikki 2017 年 1 月 20 日
First Initialized Vector Y as Y=zeros(100x48). Also introduced Coder.varsize('Y',[1000 48],[1 0]). Coder.varsize will allow Y to change its size according to result during simulation. It does worked out for me. for more details on to use coder.varsize look at coder.varsize

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by