Generate ramp signal for a certain time in simulink

91 ビュー (過去 30 日間)
Cesar Herbas Zeballos
Cesar Herbas Zeballos 2018 年 9 月 4 日
コメント済み: Wycliff Dembe 2021 年 9 月 20 日
Greetings ... I am new to the community, as well as Matlab, I would like to know how I can generate a ramp signal which lasts a certain time, since the ramp signal of the source library does not have the possibility to change this configure this parameter. So far I have tried to implement my own block in MATLAB fuction.
function y = fcn(slope,rise_time,start_time)
%#codegen
t = start_time:rise_time;
y = slope*t;
But I only get the following error.
  • Output 'y' you have variable size but the upper bound is not specified;explicit upper bound must be provided.*
  1 件のコメント
VARSSHA P
VARSSHA P 2020 年 11 月 21 日
ramp signal with time period 4 secs

サインインしてコメントする。

回答 (2 件)

Siddharth Tripathi
Siddharth Tripathi 2021 年 3 月 10 日
Hey Cesar,you can use two ramp functions in simulink with the starting time of one set at the time when you want to start the ramp function and another with its slope having a negative value of and starting time set to when you want to end the ramp input.
  1 件のコメント
Wycliff Dembe
Wycliff Dembe 2021 年 9 月 20 日
Thanks you've saved my day

サインインしてコメントする。


TAB
TAB 2018 年 9 月 5 日
Function which you have written will generate whole Ramp in just onec call (one sample).
In Simulink, this function will be called every sample time. So this is not going to work.
Also in simulink, time base will be generated by simulink only. If you want you can read the current simulation time using Clock block.
So you can use the combination of Clock, Multiply and Compare blocks to create a signal which ramps up to cirtain time.
  1 件のコメント
Cesar Herbas Zeballos
Cesar Herbas Zeballos 2018 年 9 月 5 日
Thank you for answering TAB, I will follow your advice ... although I commented that I have some doubts when using the MATLAB function to be able to create my own customized blocks, I certainly do not know if it is the best option, since in the future I would like to generate curves graphics that are based on certain input parameters.

サインインしてコメントする。

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by