%% I have this following code:
n=10000;
g = exp(-linspace(-2,2,round(n/30)).^2);
[origsig, signal] = deal(conv(randn(n,1),g,'same'));
propnoise = 0.02;
noisepnts = randperm(n);
noisepnts = noisepnts(1:round(n*propnoise));
for ti = 1:length(noisepnts)
tidx = noisepnts(ti):noisepnts(ti)+ceil(rand*10);
signal(tidx) = NaN;
end
%%
islands = bwconncomp (~isfinite(signal));
islands.N = cellfun(@length,islands.PixelIdxList);
filtsig = signal;
for ii = 1:islands.NumObjects
bndpoints = [islands.PixelIdxList{ii}(1)-1 islands.PixelIdxList{ii}(end)+1];
if bndpoints(1)<1 || bndpoints(2)>n
continue
end
linterp = linspace(0,1,islands.N(ii)+2)*diff(signal(bndpoints)) + signal(bndpoints(1));
filtsig(bndpoints(1):bndpoints(2)) = linterp;
end

댓글 수: 3

DGM
DGM 2021년 11월 20일
편집: DGM 2021년 11월 20일
What is your question?
Walter Roberson
Walter Roberson 2021년 11월 20일
I do not see a question? You showed your code but I do not see where you ask for information or advice?
Jae Won Lee
Jae Won Lee 2021년 11월 21일
Hi,
I have made the time series with using a faulty device that could eliminate the certain data points and using linear interpolation to fill in the missing values. I am wondering how I could plot these plots using bsxfun.
bsxfun(@time,[signal filtsig],???)

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

답변 (1개)

Matt J
Matt J 2021년 11월 21일
편집: Matt J 2021년 11월 21일

0 개 추천

Now idea why you think bsxfun should be involved. Why not just,
t=linspace(-2,2,n);
plot(t,signal,t,filtsig)

질문:

2021년 11월 20일

편집:

2021년 11월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by