generate HDl code by hdl coder
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How Can I implement the below given matlab code in simulink hdl coder. any Idea please?
Here is my sample code:-
[FileName,PathName,FilterIndex] = uigetfile('*.xls');
File = strcat(PathName,FileName);
[status,sheets,format] = xlsfinfo(File);
testvectordata = xlsread(File,sheets{1,1});
for i = 1:16
weight(1,i) = 0.9999;
weight(2,i) = 0.9999;
weight(3,i) = 0.9999;
weight(4,i) = 0.9999;
end
for n=1:size(testvectordata,1)-1
input(n,1) = testvectordata(n,1);
input(n,2) = testvectordata(n,2);
end
Input_a = input(:,1);
Input_b = input(:,2);
Input_a = Input_a';
Input_a_c = 1 - Input_a;
Input_b = Input_b';
Input_b_c = 1 - Input_b;
for i = 1:size(Input_a') % Number of samples
%%input sample to the BLOCK
%=====================================================================
in_data = [Input_a(1,i);Input_a_c(1,i);Input_b(1,i);Input_b_c(1,i)];
for j = 1:16 % 16 parallel nodes and each node has 4 weights
match(:,j) = min(in_data,weight(:,j));
MatchVector_Sum = sum(match(:,j));
Weight_Sum = sum(weight(:,j));
if ((MatchVector_Sum/2) >= vigilance )
Test(j) = MatchVector_Sum/(0.1 + Weight_Sum);
else
Test(j) = 0;
end
end
[TJ,Index] = max(Test);
id = Index(1);
weight(:,id) = match(:,id); % Update weight
Category = [Category;id];
%==============================================================
end
0 commentaires
Réponse acceptée
Walter Roberson
le 6 Avr 2011
uigetfile() and xlsread() would be difficult to translate into HDL.
Have you checked the Embedded Matlab documentation as to what is permitted in functions to be translated into HDL ?
3 commentaires
Walter Roberson
le 6 Avr 2011
I don't see anything _obvious_ that could not be converted. Have you read the Embedded Matlab documentation and tried using emlmex http://www.mathworks.com/help/toolbox/eml/ref/emlmex.html to be sure that your code is able to be converted to HDL ?
Are you looking for a guide to converting Embedded MATLAB functions to HDL, or are you looking for information on how to form the embedded equivalent of something specific that the embedded system is not able to translate?
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!