필터 지우기
필터 지우기

Determine number of steps in a specific frequency cycle

조회 수: 6 (최근 30일)
Raymond Elliott
Raymond Elliott 2024년 6월 27일
답변: Karanjot 2024년 6월 28일
I have a simulink model that outputs a continous step count at a constant rate. However, I would like to add a bit of code that inputs the step count and outputs the total number of steps taken in 1 second. I tried using a triggered subsystem that uses a pulse generator block, to no avail. Any help is greatly appreciated.

답변 (1개)

Karanjot
Karanjot 2024년 6월 28일
Hi Raymond,
To determine the number of steps in a specific frequency cycle (e.g., 1 second) in your Simulink model, you can use a combination of blocks to count the steps within the desired time frame.
First, create a counter for steps by using a counter block to continuously count the steps. Next, sample the counter at specific intervals by employing a triggered subsystem or a sample time block to capture the counter value at 1-second intervals. Finally, calculate the number of steps in each interval by subtracting the previous sampled value from the current sampled value, which will give you the total number of steps taken in each 1-second period.
More Implementation details are as follows:
Counter Block:
  • Use an Integrator block to accumulate the step count if you have a continuous signal.
  • Alternatively, use a Counter block if you have discrete steps.
Triggered Subsystem:
  • Create a triggered subsystem that triggers every 1 second. You can use a Pulse Generator block configured with a period of 1 second and a sample time of your simulation step size.
Store Previous Value:
  • Use a Memory block to store the previous value of the counter.
Subtract to Get Steps in 1 Second:
  • Use a Subtract block to subtract the previous value from the current value.
I hope this helps!

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by