How to decrease matrix dimension and keep maximum details by using interp1 or other functions?

1 view (last 30 days)
Hello all,
I'm currently being stuck on an interpolation problem which is a small part of bigger program. I have a matrix of Lar which has size of [1*46] and another matrix (call it airgap) with [1*360] points. I must multiply these two matrixes and put it in a bigger matrix which only accept a matrix with a dimension of [1*46]. My problem is here, I can use interp1 and change the size of Lar from [1*46] to [1*360] but I need to have matrix with a dimension of [1*46]. When again use interp1 to change the dimension to [1*46] since airgap matrix has many details, interp1 doesn’t work at all. Any idea how can I solve this problem?
This is matrix Lar:
This is matrix airgap:
shift=0:2*pi/45:2*pi;
phi = 0:2*pi/359:2*pi;
new_Lar_points = interp1(shift,Lar,phi);
a=new_Lar_points.*airgap;
a:
Using the interp1 for second time to return the matrix to [1*46] dimension:
Lar2 = interp1(phi,a,shift);
  2 Comments
Walter Roberson
Walter Roberson on 5 May 2015
Note that as your Lar and phi are periodic, you should adjust to avoid transients at the boundary. Copy the last element before the first, and copy the first element after the last, do the work giving you a 1+46+1 long result, and then discard the first and last.
Walter Roberson
Walter Roberson on 5 May 2015
This is not my area of study, but I wonder whether what you are doing is equivalent to a circular convolution?
A Discrete FIR Filter might possibly be a suitable representation; see the discussions under Simulink, here and here

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 6 May 2015
Edited: Walter Roberson on 6 May 2015
The desired output is not well defined.
You have a very jumpy vector, "a", and you are asking to interpolate it. But what should that look like?
The call you are using to interp1() is doing linear interpolation. You are effectively getting subsampling or weighted average of adjacent samples that might be very different: that is what leads to the ragged edges in the output.
You might do better if you use 'pchip' or 'spline' interpolation, but again you are going to end up being grossly affected by local features, I suspect.
Is your airgap really a high frequency sine wave? I cannot tell from the plot whether it is "flat" on top and bottom as a drawing artifact or if there are samples very close together there, such as if you are representing a comb filter. And if there are deliberately little differences in the amplitudes, if the matrix is not representing a periodic waveform, then I cannot see that visually in that plot.
I have a suspicion that the fft approach would fit your problem well, at least on a theoretical standpoint. There might be discrete convolution such as FIR that produces the same results, but I suspect that with the fft you will feel more comfortable that you are getting out "the best results possible under the circumstances". But using the fft representation does carry with it the implication that your Lar matrix is intended to represent a periodic condition.
Once you have the fft representation of the convolution, to get your output Lar2 you would use ifft() with length(Lar) as the second parameter to achieve the interpolation back to a vector the same size as Lar.

Babak
Babak on 6 May 2015
Hi Walter,
Thank you for your reply. Some quick answers to your questions:
- The desired output should look like matrix “a” but it must be represented by 46 points which seems impossible since we miss many details.
- I used spline but didn’t get a better result. I should try ‘pchip’ too.
- My airgap is really high frequency component. In reality the airgap function represent the distance between rotor and stator by considering the slot effect. In addition the figure has rectangular shape and is periodic function.
- The airgap function is 36 pulses from 0 to 2*PI and for sure there is a deliberate difference between amplitudes.
- My intended matrix ‘Lar’ is a periodic function but I am not sure if fft can help me!
  1 Comment
Walter Roberson
Walter Roberson on 6 May 2015
Edited: Walter Roberson on 6 May 2015
With both the airgap and Lar being periodic, circular convolution should be appropriate. The theoretic foundation at http://www.mathworks.com/help/signal/ug/linear-and-circular-convolution.html for two vectors of different lengths should do. You could use the fft approach, see wikipedia or you could use the FIR approach as given on the Mathworks page; they should be equivalent.
I expect that you will still end up pretty unhappy with the result, but at least you would have used a theoretic approach that assures you that you really can't do any better. If nothing else that will stop you from trying to find "more accurate" ways.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!