HDL Coder linspace block for Simulink

10 views (last 30 days)
DN
DN on 19 Jul 2016
Commented: DN on 21 Jul 2016
Hi, does anyone know if there is already a linspace() block for HDL coder which I can use in a Simulink design. I know you can just use a "user defined function block", given most HDL Coder Matlab scripts you see contain a linspace() command somewhere anyway, so it's nothing revolutionary, but I was wondering more from a aesthetically pleasing point of view to keep everything within Simulink if there is no block already in a library which I cant see.
Thanks in advance

Accepted Answer

Tim McBrayer
Tim McBrayer on 19 Jul 2016
As I understand it you want a constant value in Simulink that emulates the linspace command. If this is what you are asking for, you can just use a Constant block, where the constant value is specified using the linspace function.
For example, if a Constant block has its constant value set to:
linspace(0, 7, 16)
You get a 16-element vector evenly spaced over the range [0, 7] as the output.
  3 Comments
DN
DN on 21 Jul 2016
Eehmm...I think you misunderstand with the 1st paragraph, 2nd one I agree....but 1st paragraph it's not "divided into arbitrary number of segments". Look at the equation, 100 is fixed, only the range changes, which can just be persistent variables, right? You must just make sure you your tick your variable size in your output ports of your user defined function block.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!