필터 지우기
필터 지우기

I am having trouble smoothing my data.

조회 수: 1 (최근 30일)
daniel
daniel 2015년 3월 4일
댓글: daniel 2015년 3월 5일
I have some data I need to do a bit of analysis on but I am having trouble getting it in the correct form. I have attached a fig for your viewing pleasure.
As you can see I have two set of data, one is beautiful (relatively smooth and continuous in red) the other is all over the place. The spikes you see are do to gap fills and I am not sure why it behaves this way but it seems that these "gap-fills" are interpolated data but scaled up. I need to connect the higher "gap-fills" with the lower values but I am not sure how to go about it. I have tried a few things but nothing is working as well as I'd like. First I got rid of the spikes and replaced them with NaN's then interpolated those gaps but it was not what I needed. Any help is appreciated! Thanks!

답변 (1개)

Image Analyst
Image Analyst 2015년 3월 4일
Why do you need the gaps filled instead of just removing them?
newSignal = signal(signal<6500);
newTimes = times(signal<6500);
plot(newTimes, newSignal);
If you really need the new, repaired signal at all the same times that the old signal has (for some reason, but why???), then use interp1
goodSignal = signal(signal<6500);
goodTimes = times(signal<6500);
repairedSignal = interp1(goodTimes, goodSignal, times);
  댓글 수: 5
Image Analyst
Image Analyst 2015년 3월 5일
daniel, let me try to make my case to you. I tried to recreate your signal by making a sine wave and then adding huge spiky noise to it. Then I removed the spikes and interpolated what's left. It gave a pretty darn good representation of the perfect cosine wave signal. It is not "very unrealistic", at least to my eyes. I think it looks great. What do you think?
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
times = 1 : 600;
signal = 50*cosd(times) + 6100;
% Add noise
randomLocations = randperm(length(signal), 100);
signal(randomLocations) = 8200;
% Plot it.
subplot(2, 1, 1);
plot(signal, 'b-', 'LineWidth', 2);
title('Original, Corrupted Signal', 'FontSize', fontSize);
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Find "good" parts of the signal.
goodSignal = signal(signal<6500);
goodTimes = times(signal<6500);
repairedSignal = interp1(goodTimes, goodSignal, times);
subplot(2, 1, 2);
plot(repairedSignal, 'b-', 'LineWidth', 2);
grid on;
title('Repaired Signal', 'FontSize', fontSize);
daniel
daniel 2015년 3월 5일
This is isn't a pissing contest if you don't like my explanation it's cool, I am not here to get into an argument. I came on here to get some help, which I did. This isn't randomly generated data this is real life, I need as much of the original signal as possible. If you don't understand "why" I am sorry, enjoy your day ;)

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

카테고리

Help CenterFile Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by