Constant block only outputs a single data point

Hi everyone,
Constant blocks in Simulink have started behaving strangely for me very suddenly. As in the title - the constant block only outputs a single data point at t=0, otherwise it does not output a value. I have tried everything I can think of short of reinstalling MATLAB. The issue occurs across all my models and doesn't seem to be affected by any settings, including the solver settings. To prove this point I have created a model containing only a constant block, scope, and workspace output. Please see the screenshots below.
I have tried replacing the constant with a step, and this doesn't produce much better results.
I am fairly sure this is a bug, since it came on so suddenly and without any real change in any of my models or settings. I'm just wondering if anybody else has had this issue or knows of a workaround. I am highly dependent on Simulink for my university course, and since this renders it basically useless I am really keen to get it sorted.
Many thanks.

댓글 수: 7

Paul
Paul 2020년 12월 23일
Have you verified that that the Stop Time of the simulation hasn't been inadvertently set to zero?
Yes, the stop time is 10 seconds in the example I posted. The problem occurs across all my models, with differing solver parameters that have all worked fine in the past.
Paul
Paul 2020년 12월 24일
What happens in the model you posted if you add another source, like a sine wave, and connect it to scope? Does that verify that the simulation runs for the full 10 seconds?
John Smith
John Smith 2020년 12월 24일
편집: John Smith 2020년 12월 24일
Interestingly there is no problem when I add a sine wave (see screenshot). However, when I comment out the sine wave the constant block goes back to behaving as previously. It seems that Simulink solves for the system only when you force-feed it with dynamics.
Paul
Paul 2020년 12월 24일
I'm still wondering if in the first case the simulation didn't actually run for the full 10 seconds for some reason. What is out.tout in that case?
I ran my own model (2019A) of Constant feeding a To Workpace and Scope with all of the default solver settings and didn't have a problem.
The first case simulation is running for the full 10 seconds. out.tout contains time values from 0 to 10 at intervals of 0.2, and out.const only contains a single '1' at t=0. Really strange behaviour. I'm running R2020b, by the way.
Paul
Paul 2020년 12월 24일
Maybe send a simple model that illustrates the problem to Tech Support and see what they say? If you do and they solve the problem or identify an issue, please post back here with the results.

댓글을 달려면 로그인하십시오.

답변 (2개)

Mark McBroom
Mark McBroom 2020년 12월 25일

0 개 추천

What is the sample time for the constant block? The default is "inf" which indicates constant sample time. Change this to -1 or 0.2 and you will see data plotted each time step. See this description of constant sample time. https://www.mathworks.com/help/simulink/ug/types-of-sample-time.html

댓글 수: 2

I am using the default sample time of "inf" in the constant block. I have always used this sample time in the past and never had a problem. If I set a sample time of -1, sampling does occur at each time step. However, for some of my models with fast dynamics this doesn't seem to solve the problem. I get a constant output of zero where I used to get the expected output. I am doubtful that it is a problem with any of my model parameters, since the issue came completely out of the blue and without me making any changes.
When a constant block has a value of "inf", Simulink only computes its output one time because it never changes during the simulation. What problem are you trying actually trying to solve? Do you have workspace parameters in your constant blocks? Are you trying to tune then during the course of a simulation and not seeing the newly tuned value take effect in your Simulink model?

댓글을 달려면 로그인하십시오.

sregmi
sregmi 2024년 7월 24일

0 개 추천

I have the same issue. I am on R2024a.
The output on the scope is a single datapoint while the same output on Simulink data inspector is datapoints across the time (which is what we expect).

카테고리

도움말 센터File Exchange에서 General Applications에 대해 자세히 알아보기

제품

질문:

2020년 12월 23일

답변:

2024년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by