How to find indices of array in hdl coder?

I am trying to work on a hdl code using matlab with hdl coder.The matlab code generates it into fixed point code sucessfully but when i try to convert the fixed point code to hdl format,I am facing some issues constantly.The code has part about finding the various indices of an array using if condition in which the error arises.
The error I am getting is:
ErrorFound an unsupported unbounded loop structure, at Function 'ifWhileCond' (#96.698.975), line 31, column 1 Function 'ifWhileCond' (#96.455.469), line 18, column 13 Function 'segmentationHDLdesign_fixpt' (#1.1070.1146), line 32, column 5. This loop may be user written or automatically generated due to the use of specific vector expressions or functions.
Code:
% %columnwise histogram segmentation
for i=1:n
if(image(:,i)==b)
y(i)=i;
end
end
col=zeros(1,322);
k=1;
for i=1:322
if(y(i)==0)
col(k)=i;
k=k+1;
end
end

6 commentaires

if(image(:,i)==b)
It would be clearer if you explicitly coded
if all(image(:,i)==b)
Maybe
k = 0;
for i = 1:322
if y(i)
k = k + 1;
y(k) = y(i);
y(i) = 0;
end
end
with no col array.
Siddarth S
Siddarth S le 26 Fév 2024
Modifié(e) : Siddarth S le 26 Fév 2024
I am not having any issues with the first loop.The main problem arises in the second loop.I will definitely try your solution and get back
Walter Roberson
Walter Roberson le 26 Fév 2024
Modifié(e) : Walter Roberson le 26 Fév 2024
k = 0;
for i = 1:322
if y(i)
k = k + 1;
if k ~= i
y(k) = y(i);
y(i) = 0;
end
end
end
y = y(1:k);
Siddarth S
Siddarth S le 5 Mar 2024
Modifié(e) : Siddarth S le 5 Mar 2024
This also didn't work when I tried to transform it to hdl form.Same issue arised.Although when I ran both the loops in seperate codes,I was able to get the right results and the code was able to transform in HDL format with HDL coder with no issues.So can I use those functions in my main design function? Will this be considered as sub blocks?
Siddarth S
Siddarth S le 5 Mar 2024
I would also like the give context that the code I am trying is for image segmentation code where I am trying to get the text from image.I am trying for histogram segmentation where I detect the rows and columns for the presence of text and cut the image accordingly.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Code Generation dans Centre d'aide et File Exchange

Produits

Version

R2023a

Question posée :

le 25 Fév 2024

Modifié(e) :

le 5 Mar 2024

Community Treasure Hunt

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

Start Hunting!

Translated by