I'm searching for an algorithm for resizing a RF sampled signal in order to draw it without losing any important maximum or minimum values.

The values of the vector are negative/positive around zero.

The signal in 1:1 scale

The signal in 2:1 scale

  • 2
    $\begingroup$ I like Peter's answer, but I agree with him that this might not be what you want: Can you show a quick and dirty drawing of what you mean? Why is it important that it's an RF signal? "Drawing" implies you're using some software to do the drawing; what is that? Are you really asking us how to scale values with a factor, or how to set the boundaries of a drawing function? $\endgroup$ – Marcus Müller Jun 28 '16 at 12:47
  • $\begingroup$ It's important that it's RF signal because the meaning of the negative and positive values is crucial here. I need to scale down the drawing and still preserve the minimum and maximum values. I'm using my own drawing software to draw the signal. And yes, I simply need to scale the size of the sampled vector in such a way the the min/max values are still visible. $\endgroup$ – Tsikon Jun 28 '16 at 13:13
  • $\begingroup$ I'm using my own algorithm to calculate the values to draw. Obviously it's wrong. You can see that the scaled (lower) drawing is missing important peaks that are shown in the 1:1 scaled (upper) drawing. $\endgroup$ – Tsikon Jun 28 '16 at 13:28
  • $\begingroup$ Did you just decimate the signal to get the bottom figure from the top figure (i.e., did you just use every $n^{th}$ value)? $\endgroup$ – Matt L. Jun 28 '16 at 14:27
  • $\begingroup$ Due to the nature of your original drawing there are lines of one pixel width, whose coarse scaling is not possible from the plot. Instead, I suggest, you may consult to the original high-resoution RF data and resample it to fit into your new waveform display size. Now it shall preserve all the important peaks, as long as the original RF signal was oversampled enough. $\endgroup$ – Fat32 Jun 28 '16 at 14:29

Probably not what you want, but using the convex hull of your points will preserve the minima and maxima.

Convex hull of noise.

R Code Below

T <- 1000
x <- rnorm(T,0,1)

ix <- seq(1,T)

ix_hpts <- chull(x = ix, y= x)

plot(ix_hpts, x[ix_hpts], type='l', col='red')
points(ix, x)

Just find the maximum and minimum value of your data; find the absmax:= max(abs(min(data),max(data))). Scale your values by factor:=height_of_window/2/absmax.

The y-coordinate of your data point will by y:= value * factor + height / 2 to keep the x=0 line centered in your drawing.

That's pretty basic (read: ninth grade) solving of linear equations...

  • $\begingroup$ Hi Marcus, either I didn't understand your answer or you didn't understand my Question. I'm not interesting in scaling the height, that is indeed basic calculations. I'm interested in scaling the width. for example, drawing X sampled points on to X/2 pixels. $\endgroup$ – Tsikon Jun 29 '16 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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