LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interpolation between two complex number

Dear all,

I have two arrays-1D with complex number. and I want to do interpolation between these two arrays. I found some examples but they were real number and I am having complex numbers. Thus, I am wondering if there is someone can help me to sort out this issue? 

More information in the attached thread.Thanks in advance

 

Best regards

 

0 Kudos
Message 1 of 17
(5,787 Views)

Just so I am clear, what does it mean to interpolate a complex number? If you want a value halfway between (2 + 2i) and (4 - 4i) would it be (3 - 1i)?

0 Kudos
Message 2 of 17
(5,781 Views)

All your VI has is two complex arrays so it is not clear what you actually want. As has already been mentioned, you need to define what "interpolate" actually means in your case.

 

  • Do you want to interpolate RE and IM individually?
  • is RE=x and IM=y and you want to interpolate IM for any new RE? (such as if you graph complex data on an xy graph).
  • Interpolation typically works on one array. What is the purpose of the second array?
  • What result do you expect from the current default values?
  • If we graph your current data RE vs IM, we get the two curves shown. I cannot image what "interpolate" could possibly mean.

 

InterpolateComplex.png

Message 3 of 17
(5,756 Views)

Besides interpolating Re and I'm independently, you might instead want to interpolate the phase and magnitude independently. You have to decide if he phase is interpolated clockwise, counterclockwise or smallest path. This is very resemblant of how a dds ramps up amplitude and\or phase. Or interpolating colors in hsl space. Don't think it makes sense in this situation though.

 

I'd think you want to interpolate x and y values. It won't do you any good. The interpolated values will be on the straight lines already drawn, you'll just get points on that line.

 

I think you need some sort of 2d curve fitting instead.

Message 4 of 17
(5,732 Views)

The OP's description of the problem (suggested also by the title) is to interpolate between two complex arrays.  The "natural" way to think about this is the result will be another 1D array whose value is Result = (1-k)*A + k*B, where A and B are the original arrays, and k is a value between 0 and 1 (if k = 0.5, you'd get the mid-point between A and B).  Looking at the data that Altenbach kindly posted, these curves have very similar character, but are displaced and rotated slightly.

 

Bob Schor

Message 5 of 17
(5,716 Views)

I'd guess the intention is to make a smoother curve. Interpolation won't help.

So simply interpolation between all Re values of the first and second array, and I'm values of both would be useful. If the first array is a measurement, and the second is a measurement too, the result would be a measurement in between.

 

That would simply be a matter of

1) split the array1 in Re and I'm arrays (complex to Re\Im)

2) split the array2 in Re and I'm arrays (complex to Re\Im)

3) Interpolate between array1.Re and array2.Re

4) Interpolate between array1.Im and array2.Im

5) merge the results with Re\Im to complex

 

3) and 4) is simply  (b-a)*I+a.

 

Might post a vi tomorrow if nobody done so by then.

 

Message 6 of 17
(5,705 Views)

Well, he could do a spline on RE and IM as a function of array index (e.g. time) with 10x more points. (example)

Message 7 of 17
(5,698 Views)

Well, here's what my assumed solution looks like. Slide=0.2.

 

Would be nice to get any feedback on what OP wants...

Forum.pngForum BD.png

Message 8 of 17
(5,668 Views)

Here's what I had in mind, but probably solves a completely different problem. 😄

 

SplinerXY.png

 

Message 9 of 17
(5,641 Views)

Looking at Christian's lovely Spline drawing, it suddenly came to me what "interpolation" might mean (or certainly a case where it could be useful).  I'd noted earlier when I saw the original plot that these two curves looked similar.  So let's assume that they represent a set of ordered points (perhaps coordinates of a path on the surface of some deformable object).  Let me further assume that I take two "snapshots" of these points at time T0 and T1, and I'm interested in how the underlying object "evolves" over time.  So I divide the elapsed time, T1-T0, into N intervals, and make a movie where the first frame is the curve at time T0, Frame N+1 is the curve at time T1, and intermediate frames are interpolations between the two curves at position i/N (hmm, I may have an "off-by-one" error here, but you get the idea).  As you watch such a movie, you'll see it start with one curve, the smoothly translate, rotate somewhat, and maybe get some distortion, ending up as the second curve.

 

It is an entirely separate question if this is a sensible thing to do, and if this is what the O.P. is trying to accomplish ...

 

Bob Schor

Message 10 of 17
(5,635 Views)