# Digital RF signal vector resize algorithm

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.  • 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? – Marcus Müller Jun 28 '16 at 12:47
• 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. – Tsikon Jun 28 '16 at 13:13
• 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. – Tsikon Jun 28 '16 at 13:28
• 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)? – Matt L. Jun 28 '16 at 14:27
• 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. – 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. R Code Below

#31780
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...

• 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. – Tsikon Jun 29 '16 at 8:10