Effacer les filtres
Effacer les filtres

Error - 'All inputs must be constant' in MATLAB Coder

6 vues (au cours des 30 derniers jours)
Puneet Khurana
Puneet Khurana le 26 Déc 2017
Commenté : Walter Roberson le 27 Déc 2017
I am trying to convert the function poly2trellis into C using MATLAB Coder. The problem arise when I check the issues in the Coder App and it displays the error that ' all inputs must be constant'.
function [ trellis ] = con_poly2trellis(k) %#codegen
generator_matrix=[0 0];
if k==3
generator_matrix=[5 7];
else
generator_matrix=[32 35];
end
trellis = poly2trellis(k,generator_matrix);
end
Does it mean that I can generate code for a single specific input and not based on any value passed for 'k'?
What if a generic function is required which can accept any value of 'k' and I can include multiple if-else case for generator_matrix?
Please help and suggest.

Réponse acceptée

Walter Roberson
Walter Roberson le 26 Déc 2017
if k==3
trellis = poly2trellis(3,[5,7]);
elseif k==4
And so on.
  5 commentaires
Puneet Khurana
Puneet Khurana le 27 Déc 2017
got it, thanks!!
Walter Roberson
Walter Roberson le 27 Déc 2017
It does not execute all of the function calls, it compiles all of the function calls down into the specific code needed for that one trellis variety.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Error Detection and Correction dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by