Azzera filtri
Azzera filtri

difference of a vector, diff()

4 visualizzazioni (ultimi 30 giorni)
DN
DN il 22 Lug 2016
Commentato: DN il 22 Lug 2016
Hi, I'm trying to figure out how to do a simple difference of a vector using HDL coder compatible Simulink blocks. I want to shift the bits so to speak and subtract essentially, so probably need to use some bitrol or something. I.e. I would like to implement the DIFF(X), for a vector X, being [X(2)-X(1) X(3)-X(2) ... X(n)-X(n-1)] using blocks. Thanks

Risposte (1)

Azzi Abdelmalek
Azzi Abdelmalek il 22 Lug 2016
Use Matlab function block with this code
function y = fcn(u)
%#codegen
y = diff(u);
  1 Commento
DN
DN il 22 Lug 2016
Thanks Azzi, but I don't think its that simple. Type in your command window hdllib, and you will see there is no block supported for this, nor if you look into the HDL documentation is the function diff() supported among the list of functions for HDL Coder regardless if you use a user defined function block as wrapping. Have you actually tried converting to HDL code when use the above by right clicking, not just C/C++ code generation ready but HDL, there's a difference. Perhaps I'm missing something, thanks for your help.

Accedi per commentare.

Categorie

Scopri di più su Code Generation in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by