0
$\begingroup$

I'm trying to analyze a signal like the example below, but it contains undesirable zero value samples, is there any way to eliminate them? I'm using Matlab.

Signal with zeros Actually, the problem is this: in a sampling process I am using a train of impulses but that train I formed it with the cardinal sine function and it has generated values with zeros. Then, that train multiplies it in time to the sinusoidal signal and obtain samples (samples with zeros).

k=5; 
t=0:Ts:T; 
for n=min(t):k*Ts:max(t) 
    pdirac=pdirac+sinc(100*(t-n));
end
signal=signal1.*(pdirac); 

enter image description here

$\endgroup$
4
  • $\begingroup$ In its current form, this question is not properly answerable here. Either, it's really just "how do I ignore all but the Nth values in a matlab vector (or all but the nonzero values, or...)", in which case it's not a signal processing, but a plain programming question, and hence off-topic here (and would indicated you might want to spend a couple more minutes on a Matlab tutorial). Or, your question is related to some signal property, but then you forgot to even mention that, so your question is unclear. $\endgroup$ Mar 14, 2017 at 22:14
  • $\begingroup$ Actually, the problem is this: in a sampling process I am using a train of impulses but that train I formed it with the cardinal sine function and it has generated values with zeros. Then, that train multiplies it in time to the sinusoidal signal and obtain samples (samples with zeros). $\endgroup$
    – Bkx
    Mar 15, 2017 at 1:20
  • $\begingroup$ If you can make certain guarantees on the frequency content of the signal prior to multiplying by the train of impulses, then you can cast this as an interpolation problem. Then, passing your signal through an appropriate interpolation filter will give you a meaningful result. $\endgroup$
    – hops
    Mar 15, 2017 at 7:58
  • $\begingroup$ Edit your question to include that info! $\endgroup$ Mar 15, 2017 at 8:51

2 Answers 2

2
$\begingroup$

If you just dont want to see them in your figure, just replace them with nans. Lets say that your signal is s. Then

s(s==0)=nan;
plot(s);
$\endgroup$
1
$\begingroup$
nz = 4;              % # zeros between samples
i1 = 1;              % index of first non-zero sample
y = x(i1:nz+1:end);  % signal without zeros in between samples
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.