Simulink buffer: How do I fix the error "All sample times must be discrete. No continuous or constant sample times are allowed."

I have a discrete scalar input into a simulink buffer and would like the buffer to output a 100x1 vector of the scalar inputs. However, I keep getting this error and I can't figure out why, because the input into the buffer is discrete.

 Accepted Answer

Try feeding the Buffer block with a Constant block. Changing the sample time of the Constant block from "inf" to 0.1 (for example) will result in the disappearance of this error message. "inf" means constant sample time.

5 Comments

Thanks for your help. Feeding the buffer with the constant block did not help me by itself, because the data in the buffer was not useful - I needed it to contain the values from the input. However, your comment did make me go and change the sample time of the block before the buffer to 0.1 rather than -1, which made the error message go away. Now, my question is, why did the inherited sample time fail?
That is the purpose of my answer because I don't know what type of block is feeding your Buffer block. It could be an Inport block, or an Output block from another system, or any other block, or the sample time is specified by a signal object linked to the signal line. Now you've had your model passed update, you can turn on sample time view by clicking menu Display, Sample Time, All. You will see a color indicating the input of the Buffer block has discrete sample time. "-1" (inherited) means inheriting the sample time. As long as you have a source that has discrete sample time, that should be fine. But if this is the source (for example, root level Inport block) and you still specify it as "-1", then I guess it has no sample time info, or at least it is not regarded as definitely discrete.
Thanks for your help. The diccrete sample time seems to be correct now. You're right - The block feeding into it was an enabled synchronous subsystem that I think was not definitely discrete, even though it had a discrete output.
Simulink#code generation
Error message: All sample times must be discrete. No continuous or constant sample times are allowed.
I am getting the above mentioned error while building the model in simulink. This error pertains to buffer block which is receiving bitwise data from Dspace via RS232 serial port. Please let me know how to get rid of this error. Thanks in advance.
Hello,
In my situation, i am trying to use a buffer block with ovelap to create a sliding window with 256 samples.
The output of a sample and holding block is feeding the input of buffer block.

Sign in to comment.

More Answers (2)

Hello ,
This error is persistent even when I changed the smple time to 0.1 of the input port.
Guys your help plz.

1 Comment

Try changing the sample time of the cyclic decoder input to 0.1 instead of inherited. This is what worked for me.

Sign in to comment.

I changed sample time of block from 0 to 0.001 and it works perfectly.

2 Comments

I just encountered this issue myself.
The problem is there is some block that leads into the buffer block that has the "sample time" set to 0.
That is what causes the error.
That may be the "From Workspace", "Sine Wave" block, or something similar.

Sign in to comment.

Products

Asked:

on 1 Nov 2018

Commented:

on 28 Mar 2026 at 3:56

Community Treasure Hunt

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

Start Hunting!