필터 지우기
필터 지우기

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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by