Error with Calling "dcmecef2ned" in Simulink

I am trying to run a Simulink model I initially created with Matlab 2022b on 2024b. I get the following error when I try to run the code.
"Function 'dcmecef2ned' not supported for code generation."
It use to work, but now it does not on 2024b. Is there a fix for this?

Réponses (1)

Paul
Paul le 19 Nov 2025

0 votes

Hi Richard,
In which version did it used to work? I'm assuming you're calling dcmecef2ned from inside a MatlabFunction block?
Maybe the block Direction Cosine Matrix ECEF to NED would be helpful?

4 commentaires

Richard
Richard le 19 Nov 2025
Modifié(e) : Richard le 19 Nov 2025
Paul, I am using Matlab 2024b. The dcmecef2ned function is in the Aerospace Toolbox. The function is embedded in a user-defined Matlab function block that I am calling within my Simulink model, thus I can't use the block Direction Cosine Matrix ECEF to NED.
I ended up coping the function, renaming it to "my_dcmecef2ned.m" and deleting the error checking at the beginning of the script. I modified the following function call in the script as follows:
Was:
angles = convang( [lat(:) lon(:)] ,'deg','rad');
Is:
angles = deg2rad([lat lon]);
This worked. I am not sure why I can't use the default function in Matlab.
Paul
Paul le 19 Nov 2025
The cited doc page does not include an "Extended Capabilities" section indicating that the function is eligible for Code Generation. So I'm not surprised that it doesn't work inside the MatlabFunction block. I'm more surprised that it did work in a previous version, hence my question regarding which version that was.
Richard
Richard le 3 Déc 2025
Paul, I was using this with Matlab 2022b with no issues.
Seeing same issue with code not being generated on R2024A.
If you want to use the toolbox function, then you need to declare it in the Matlab Function block using coder.extrinsic and preallocate the output. Might slow down the runtime, but you might not notice. Something like this:
function y = fcn(u)
coder.extrinsic('dcmecef2ned');
y = zeros(3,3);
y = dcmecef2ned(u(1),u(2));
end
If you want to stay with your current solution then you might consider not using the deg2rad and instead compute cang and sang wth cosd and sind respectively. Then you'll get the exact results as expected for the angles of 90,180,270 which can be nice for test cases (at a minimum).

Connectez-vous pour commenter.

Catégories

En savoir plus sur Aerospace Applications dans Centre d'aide et File Exchange

Produits

Version

R2024b

Question posée :

le 18 Nov 2025

Commenté :

le 3 Déc 2025

Community Treasure Hunt

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

Start Hunting!

Translated by