フィルターのクリア

How to realize linear function (filter?) with saturation?

2 ビュー (過去 30 日間)
Alexander
Alexander 2021 年 5 月 2 日
コメント済み: Alexander 2021 年 5 月 2 日
Initial signal equals ones, then minus ones (it can switch many times):
u = [ones(15,1);-ones(5,1)];
If u==1 then output should be .1; .2... up to 1 and stay 1 (saturation). After u==-1 the output should be -.1; -.2... up to -1.
I tried filter:
Nb = 10;
b = ones(1,Nb)/Nb;
y = filter(b,1,u);
stem([u, y])
It's wrong:
How to make transform function (maybe filter)?

採用された回答

Jan
Jan 2021 年 5 月 2 日
編集済み: Jan 2021 年 5 月 2 日
u = [ones(15,1);-ones(5,1)];
Ramp = 0.1:0.1:1; % Set of values
v = SaturatedRamp(u, Ramp);
function v = SaturatedRamp(u, R)
% Running index, starting from 1 at each change:
k = [false; diff(u(:)) ~= 0];
s = [1; find(k)];
I = ones(numel(u), 1);
I(k) = 1 - diff(s);
I = cumsum(I);
R = R(:);
I = min(numel(R), I); % Limit indices to length of ramp
v = R(I) .* u(:); % Copy sign of original data
end
  1 件のコメント
Alexander
Alexander 2021 年 5 月 2 日
Thank you very much, Jan!
(I looked through function
ischange(A,'linear','Threshold',THR);
how it plots the results.)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFrequency Transformations についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by