MATLAB Answers


vectors to scalars with an Embedded Matlab Function

Asked by Owen
on 15 Nov 2012


can anyone show me how to convert a 10x1 vector into 10 scalars with an Embedded Matlab Function?

I just don't know how to upsample the incoming vector, that is, the sample frequency at the output must be 10 times greater than at the input.

Thanks Senmeis


3 Answers

Answer by Kaustubha Govind
on 15 Nov 2012
 Accepted answer

Are you attempting to use the Embedded MATLAB Function block to perform upsampling? If so, I don't think that is possible, because the Embedded MATLAB Function block runs at an "inherited" sample-time, which means that the output must have the same sample rate as the input. It looks like what you really need is an Unbuffer block.


What about Level-2 S Function?


Sure, you have a lot of flexibility with S-functions, so you should be able to use them too.

Answer by Azzi Abdelmalek
on 16 Nov 2012
Edited by Azzi Abdelmalek
on 16 Nov 2012

You can use a Demux block from Simulink/Signal Routing. At the output of Demux you will have 10 scalar at the same time. If you want them one after one, add an Index Vector block.

look at the use of Index Vector at


I've tried Demux block and I'm afraid it cannot be used with variable-sized data.


Ah, I did'nt understand, I confused with variable step size. Then try Kaustubha's suggestion, you will need a communication system toolbox

Azzi: I didn't recommend Demux block originally because Owen wants to effectively "upsample" (or Unbuffer) the signal.

Answer by Owen
on 21 Nov 2012

I've made it with an Embedded Matlab Function. For the sample time for each element I use the Repeating Sequence Stair block. Thank you anyway.



Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!