[Simulink] How to process 2D vector row by row with gaps between rows

5 次查看(过去 30 天)
Dear expert,
Need to process a 2D vector, row by row with enable signal. I am trying to select a row (by using DSP toolkit | Select row) first; then use ubuffer to get elements.
The challenging part is to introduce gaps between rows, my row processing unit is a gated block, active only upon enable pulse signal.
  • Enable signal sample time = 1;
  • Row select logic sample time = row_width;I wish the vector is sampled only once per row, then the processing block can take row_width sample time to process the row. Then wait a bit before moving onto the next row.
I could get this to work only by having the gap width equal to the row_width or no gap at all. Because of the Select Rows block nature of item#2 in the following notes, I am stuck with the enabling pulse of duty cycle of 50%.
Not able to sample the 2-D vector at rate of other than N*row_width (because of Ubuffer) which is understandable.
I've also tried using trigger/enable on the Select row block, but the subsystem could only inherit sampling rate from the index port which is "1", the Unbuffered elements became 1/row_width each.
But is there a way to get asynchronous type of row selection?
  • For example, all I want is to fetch a row, and do something. When done fetch another row.
Please comment
Found some interesting facts about Simulink block (for example):
  1. Can use enable to gate Unbuffer, but if the enable pulse is any shorter than the frame length, there is no output at all.
  2. DSP toolkit | Select Rows continuously spit out row one even if Idx port has "0" (Index mode: One-based)

回答(1 个)

legendbb
legendbb 2012-7-26
I will answer my own question after finding a solution.
Simulink is very obvious at continuous signal for jump start user, complex discrete signals not that obvious; unless you can hold your breath by going through those amazing user guide (indeed great documentation, but just takes so long and so much repetition to get the point.)
First of all gaps can be created by concatenating 2D array with extra columns by using "Matrix Concatenate block".
After this step, depends on the enable signal and sample time pairing. An Unbuffer or Variable Selector can be used.
"DSP toolkit | Variable Selector" produces continuous signal, make this block "enabled" by using "enable" can gate the output. Unbuffer output can also be gated by using a "Switch" otherwise Unbuffer will hold the last value when the enable signal is deserted.
One of the lesson I learnt from the course of making the subsystem work, maybe helpful for hardware designers, when working with Simulink matrix and signal routings think less or think no hardware at all; mind only the signal path, block I/Os, block process finishes at exact simulation time, no processing delay. Put a scope and narrow down to the problem.
I didn't remove the original question. Wish my blah, blah, ... could eventually help someone struggle the similar way as I did.

Community Treasure Hunt

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

Start Hunting!

Translated by