Generating C Code from Matlab Code containing ODE15s Solver

6 次查看(过去 30 天)
Hi Everyone,
I'm trying to generate a c code from my matlab code using matlab coder. My matlab function contains a set of variable as an output from a ode15s solver. I have tried everything to define the output vector and matrice before calling the ode function but I receive the error "undefined variable or function" both for the time vectore "T" and the matrice of variables:
T=double(zeros((tdis*tend-tstart),1));
Y=double(zeros((tdis*tend-tstart),(z_n+1)*(n_seg*tet_n+1)+(n_seg*tet_n+1)+4));
[T,Y]=ode15s(@(ttt,y) ff8(ttt,y,Inputs),Tspan,IC,options);
Can anybode help me solving this issue?
Thanks

回答(1 个)

Harald
Harald 2023-6-29
Hi Hossein,
it could be that you have not properly defined the input arguments of the function. My recommendation is to use the MATLAB Coder App (accessible through the Apps tab or by running coder from the Command Window). This will guide you through the workflow, particularly the proper definition of input arguments of the function.
If you continue to experience problems, please make the full function available that you are trying to generate code from, and the steps you are using to generate the code.
Best wishes,
Harald
  6 个评论
Hossein Sadri
Hossein Sadri 2023-6-29
. exactly at the point, where the ode15s is being called.
. MATLAB release: R2022b
. even before complinig at the point where a MEX-sample is being built and tested I receive this error.
I have tried this, nothing changed.
regards,
Harald
Harald 2023-6-29
I also tried in R2022b with compiler Microsoft Visual C++ 2017, and it worked for me.
There is only one more aspect that I can think of: check if you are using a supported compiler for R2022b. If the compiler you currently use is not listed, I recommend switching to a supported compiler.
You can use mex -setup to identify the compiler currently used.
If this does not help, please contact the Technical Support team. Referring to this page will help the colleagues understand what you have already tried.
Best wishes,
Harald

请先登录,再进行评论。

类别

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