フィルターのクリア

how to mute the signal at a certain time

1 回表示 (過去 30 日間)
Naufal Arfani
Naufal Arfani 2020 年 12 月 30 日
編集済み: Paul Hoffrichter 2021 年 1 月 4 日
I have a signal data that at t = 0 to t = 1 has a constant value of 0 and only at t = 1 etc. you can see the results, how do I get rid of the signal data contained at t = 0 to t = 1 or make the signal data reading start from t = 1

回答 (1 件)

Paul Hoffrichter
Paul Hoffrichter 2020 年 12 月 30 日
編集済み: Paul Hoffrichter 2020 年 12 月 30 日
This will remove all the leading zeros of a Sig vector:
Sig = Sig(find(Sig,1,'first'):end);
  2 件のコメント
Naufal Arfani
Naufal Arfani 2021 年 1 月 3 日
I have used this code on my simulink but it still doesn't work. Is it possible because the signal form is discrete with a sampling frequency of 1000 so that the shape [1 x 1000] can't use the code above or maybe I entered the code incorrectly? Please help me
function y = fcn(u)
Sig = u(find(u,1,'first'):end);
y = Sig;
Paul Hoffrichter
Paul Hoffrichter 2021 年 1 月 3 日
編集済み: Paul Hoffrichter 2021 年 1 月 4 日
A sampling frequency of 1000 means there are 1000 samples per second. But if your signal is [1x1000], then the duration is 1 second.
>> I have a signal data that at t = 0 to t = 1 has a constant value of 0.
I assumed your units for t was in seconds. If so, then your entire [1x1000] signal is filled with 0's. I do not see how you can have more than 1 seconds worth of data if you only have 1000 samples.
The answer I provided did not take into account your sampling frequency, Fs, since it was not mentioned. Your fcn() shifts the input, u, to the left removing all leading 0's.
close all
x = zeros(1,500);
rn = rand(1,200);
x(301:end) = rn;
figure, plot(x);
% Remove leading 0's
y = fcn(x);
figure, plot(y,'g')
function y = fcn(u)
y = u(find(u,1,'first'):end);
end

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

カテゴリ

Help Center および File ExchangeSignal Attributes and Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by