using sat(.) function i.e y=sat (x) function

조회 수: 31 (최근 30일)
Adekemi
Adekemi 2013년 11월 22일
댓글: Walter Roberson 2015년 9월 22일
Hi all,
can someone put me through this I need to use a sat function in a sliding mode control problem : below is the alternate code I saw Y=(atan(5.*s*1/e)-atan(-5.*s*1/e))/(pi); where s is the sliding manifold,e=1 but I intend to use: And is the same with sat function even though I got result
function Y=sat(s);
% % sat is the saturation function with unit limits and unit slope.
% if s>1
% Y=1;
% elseif s<-1
% Y=-1;
% else
% Y=s;
% end
  댓글 수: 2
Yousef Sardahi
Yousef Sardahi 2015년 9월 22일
편집: Walter Roberson 2015년 9월 22일
The saturation function can be coded as follows :
function y=sat(x,delta)
kk=1/delta;
% sat is the saturation function with unit limits and unit slope.
if abs(x)>delta
% elseif x<-delta
y=sign(x);
else
y=kk*x;
end
Walter Roberson
Walter Roberson 2015년 9월 22일
That code is not vectorized. A vectorized approach is
sat = @(x, delta) min(max(x/delta, -1), 1);

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

답변 (1개)

Walter Roberson
Walter Roberson 2013년 11월 22일
Your existing code would have a problem if you were to input a vector or matrix of values. I suggest instead,
sat = @(s) min(max(X, -1), 1);

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by