Unrecognized function or variable 'ramp'

조회 수: 6 (최근 30일)
Ramavatar Singh
Ramavatar Singh 2021년 2월 2일
댓글: Gwinyai Munanairi 2021년 9월 23일
% example $Signal Generation = y(t)=3r(t+3)-6r(t+1)+3r(t)-3u(t-3) %
clear all; clf;
Ts=0.01; t=-5:Ts:5 ; %Support of signal
%Ramp with support
y1=ramp(t,3,3); %slope of 3 and advanced by 3
y2=ramp(t,-6,1); %slope of -6 and advanced by 1
y3=ramp(t,3); %slope of 3
%unit step with support [-5,5]
y4=-3*unitstep(t,-3); %amplitude of -3 and delayed by -3
y=y1+y2+y3+y4;
plot(t,y);
%please tell me how to correct this
  댓글 수: 1
Gwinyai Munanairi
Gwinyai Munanairi 2021년 9월 23일
The line that says y3 = ramp(t,3) should be: y3 = ramp(t,3,0) because the ramp() function needs all three parameters, it won't run with 2 parameters. skrrrrr!

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

답변 (1개)

Walter Roberson
Walter Roberson 2021년 2월 2일
ramp() is defined only by Simulink Test toolbox https://www.mathworks.com/help/sltest/ref/ramp.html
There is also a Simulink Ramp block; https://www.mathworks.com/help/simulink/slref/ramp.html
The example at https://www.mathworks.com/help/signal/gs/impulse-step-and-ramp-functions.html shows how to create a simple ramp function:
ramp = @(t) t.*(t>=0);
Presumably your course provided you with a ramp function such as
ramp = @(t,slope,advanced) @(t) slope.*(t-advanced).*(t>=advanced)
but I could be confusing the meaning of advanced. And this function would have to be improved a bit to take into account that the advancement parameter is optional. Perhaps you are expected to code the function?

카테고리

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