Integral in Simulink fcn Block
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hey,
frist: I'm pretty new to Matlab / Simulink. I'm wrote an algorithm to generate a trajectory in Matlab and wanted to integrate my working Matlab code into a Simulink Project by using a Fcn Block.
Within my algorithm I have to integrate a cos / sin function. My code looks like:
ds = .1;
length = 1;
phi = 0;
R=5.5;
A=sqrt(R*length);
i=1;
int_x1=@(l) cos((l.^2/(2*A.^2)) + phi);
int_y1=@(l) sin((l.^2/(2*A.^2)) + phi);
x=zeros(1,(length / ds)+1);
y=zeros(1,(length / ds)+1);
for l=0:ds:length
x(i)=integral(int_x1,0,l);
y(i)=integral(int_y1,0,l);
i=i+1;
end
This generates x and y coords in ds steps. It builds a Clothoid for a Radius of 5.5 within a length of 1.
My Problem with Simulink is, that the integral function does not work.
"Function 'integral' not supported for code generation."
In the next step I tried to fix this by the use of:
coder.extrinsic('integral');
which leads to:
"An error occurred while running the simulation and the simulation was terminated
Caused by:
- First input argument must be a function handle. "
Is there any possibility to numerical solving of integrals within a function block?
2 Commenti
Jim Riggs
il 10 Nov 2022
I'm not sure what you are trying to do in Simulink. Can you post an image of your Simulink model, and specify exactly what code is in the Fcn block?
Risposte (1)
Fangjun Jiang
il 10 Nov 2022
You need to understand the difference between MATLAB and Simulink.
This Simulink block diagram will give you the curve. Set the values of "A" and "phi" in base workspace.
5 Commenti
Vedere anche
Categorie
Scopri di più su Programmatic Model Editing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!