merging two vectors into one that takes the second input after the first

3 views (last 30 days)
I am trying to have a feedback signal (signal 2) starts immediatly after initial signal (signal 1). Signals 1 and 2 are two vectors with time dimension at the same sampling rate. The way I thought about this is to have a merge block with a unit delay on the second input signal, but not exactly sure how to implement that in terms of the settings for the unit delay and subsystem for the merge inputs. Please help. Thanks in advance!

Answers (1)

Purvaja
Purvaja on 25 Feb 2025
Edited: Purvaja on 25 Feb 2025
I understand that you want to merge two signals, in the form of vectors, sequentially right one after the another. I have tried following steps to achieve the result:
  1. In this Simulink model, I used Constant Blocks, a Discrete-Time Integrator, Width, Compare, Switch, and Scope Blocks to concatenate and sequentially output the signals [1,1,1,1,1] and [2,2,2,2,2].
  2. Constant (1) Block: This block continuously feeds a value of 1 into the Discrete-Time Integrator, ensuring that the integrator increments at each time step.
  3. Discrete-Time Integrator: Acting as a counter, it accumulates values over time to track when the switch should occur.
  4. Constant Blocks (Signal Sources): Two constant blocks generate the signals [1,1,1,1,1] and [2,2,2,2,2], which are later selected based on the counter.
  5. Width Block: It determines the number of samples in the first signal and provides this as a reference for switching.
  6. Compare Block: This block compares the Discrete-Time Integrator output with the signal width, triggering the switch once the first signal has completed.
  7. Switch Block: It selects the first signal initially and switches to the second signal when the condition is met.
  8. Scope Block: The final concatenated signal is visualized, verifying that the sequence [1,1,1,1,1,2,2,2,2,2] is correctly formed.
It would look like this:
You can also go through following documentation link to know more about above blocks used:
  1. Constant Block: https://www.mathworks.com/help/simulink/slref/constant.html
  2. Discrete-Time Integrator Block: https://www.mathworks.com/help/simulink/slref/discretetimeintegrator.html
  3. Width Block: https://www.mathworks.com/help/simulink/slref/width.html
  4. Relational Operator Block: https://www.mathworks.com/help/simulink/slref/relationaloperator.html
  5. Switch Block: https://www.mathworks.com/help/simulink/slref/switch.html
  6. Scope Block: https://www.mathworks.com/help/simulink/slref/scope.html
Hope this works for you!!

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!