LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can you perform curve fitting to a 2d array and find the maximum?

Please attach yor VI and some data.
 
 The array ends when the elements turn grey, so you seem to have real zeroes in there. I am sure there is an easy explanation where they are coming from....
0 Kudos
Message 21 of 32
(3,377 Views)
I found the problem. When I was writing the measurements to the file, I would enter the measurement then add a space to prepare for the lat measurement. When I was done writing to the file, I was left with a space after my last entry, which was seen by the VI as an entry of (0 0 0). I simply cleaned up the file and was done with it.

Now... I have to figure out how I'm going to search for local maxima on this graph.
0 Kudos
Message 22 of 32
(3,355 Views)

Hi Christian - Did you ever get a final version of your code done?  Most likely I will just be using the polynomial fit of the surface.

 

Sincerely,

 

Don 

0 Kudos
Message 23 of 32
(3,248 Views)

Hi Don,

 

I'm pretty sure I have a decent version but I need to dig it out first. Haven't really played with this in a long time. :)l

 

I was able to fix the crash by disabling hardware acceleration on the 3D graph. I probably should rewrite it for 8.6 so it's platform independent for the 3D stuff. 🙂

 

 

Let me check....

 

 

Message Edited by altenbach on 11-19-2008 01:05 PM
0 Kudos
Message 24 of 32
(3,242 Views)

What I want to do is experiment with fitting time-frequency (energy = f(time,freq)) using polynomial (most likely) model and store coefficients rather than entire plot.  Of course, then have to be able to reconstruct the plot from the coefficients.  You can see how this might be useful as a form of data compression for thousands of plots.

 

I have not put on 8.6 yet.  Probably in about 1 month or so.  They use the 3d picture control for platform-independent 3d surface graph now is what I gather?  I have to read the upgrade notes again when I get time.

 

Sincerely,

 

Don

0 Kudos
Message 25 of 32
(3,221 Views)

Hi Don,

 

If it's a simple 2D polynomial, you have a linear system and all you need is "general LS linear fit". Setup the H matrix for all unit coefficients, and it will do the rest. No need for initial guesses, interative methods, etc.

 

I made an example for that here in the forum. (actually, I made quite a few over the years. This one is the latest discussion).

 

(You only need levenberg-Marqurdt if the system is nonlinear, e.g. if there is a 2D gaussian on top of the polynomial surface.)

0 Kudos
Message 26 of 32
(3,213 Views)

It is unclear to me how to describe this type of surface which describes a type of data applicable for this type of joint time-frequency analysis.

 

 

Message Edited by DonRoth on 11-20-2008 12:25 PM
Download All
0 Kudos
Message 27 of 32
(3,199 Views)
Well, this is certainly not a 2D polynomial. Do you have a mathematical model for it?
0 Kudos
Message 28 of 32
(3,188 Views)

I agree with altenbach: a reasonable math model is essential.  Eyeballing the figure you have posted, it looks to me like a possible model, in words, is as follows:

 

There are 2 band-limited frequencies in the signal which change their amplitudes and frequencies with time.  There appears to be a signal that turns on early in time at a low frequency.  Its center frequency gradually rises. A second component turns on later.  The 2nd component has a higher initial center frequency than the 1st one, but the 2nd signal's center frequency gradually falls while the 1st component's center freq gradually rises.  the center frequencies merge, and then both signals turn off.

 

A mathematical version of the above model in joint time-frequency space is 2 components which, at each short time slice, have a Gaussian distribution in the frequency domain, but the amplitude and center frequency of the Gaussian changes with time.  Does the "width" (i.e. bandwidth in the freq domain) change with time, and is it the smame for the 2 signals?  I can't tell from the graphs.  I assume each component has a chacteristic bandwidth "s" (like the sigma for a Gaussian distribution), and the 2 components have different bandwidths from one another, but the band widths are constant over time (s1 and s2).

 

x(f,t) = A1(t) * exp[-(f-f1c(t))^2/(2*s1^2)] + A2(t) * exp[-(f-f2c(t))^2/(2*s2^2)]

A1(t) = time-dependent amplitude of component 1 (units = z-axis units)

A2(t) = time-dependent amplitude of component 2 (units = z-axis units)

f1c(t) = time-dependent center frequency of component 1 (units=Hz)

f2c(t) = time-dependent center frequency of component 2 (units=Hz)

s1=bandwidth of component 1 (units=Hz)

s2=bandwidth of component 2 (units=Hz)

 

We stil need to come up with functional forms for A1(t), A2(t), f1c(t), and f2c(t).

 

Maybe the frequencies change linearly with time, i.e.

 

f1c(t) = a1*t + b1  (units: a1=Hz per sec=Hz^2; b1=Hz)

f2c(t) = a2*t + b2

 

The amplitudes:  Maybe thethey turn on at time Tstart, remain steady, and turn off at time Tend:

 

A1(t) = A10 if Tstart1 <= t < Tend1; A1=0 elsewhere

A2(t) = A20 if Tstart2 <= t < Tend2; A2=0 elsewhere

 

This means we have to use the joint time-frequency plot data to fit 12 parameters simultaneously:

 

Related to component 1: a1, b1, Tstart1, Tend1, s1, A10

 

Related to component 2: a2, b2, Tstart2, Tend2, s2, A20

 

Of course you could argue that model is not very reasonable, perhaps esecially with regard to the constancy of A1 and A2 while each is turned on.  If A1 and A2 turn on and turn off gradually, then you'd probably need even more parameters.

 

Maybe you think the components turn off togeher, in which case Tend1=Tend2, and you can replace both with Tend, and reduce you parameter count by 1.

 

Having done Levenburg-Marqhardt in high dimensional spaces myself (up to 10D), I can only say "good luck"!

0 Kudos
Message 29 of 32
(3,177 Views)

From a physics standpoint, let me attempt to explain things. I did not take this data but I THINK it is real-world data showing lamb wave acoustic modes traveling in an aluminum plate that has a transducer sitting on top of the plate.  The primary modes are one symmetric (longitudinal) s0 and one antisymmetric (shear) a0 mode.  initially, the longitudinal wave s0 travels faster and is therefore seen earlier in time, and is also lower in amplitude as the particle motion of the longitudinal wave is in the plane of the bar and has less of an exciting effect on the transducer element.  The shear mode travels slower and is therefore seen later in time and is higher in amplitude as the particle motion of the shear wave is perpendicular to the plane of the bar and thus impinges compressionally on the transducer and has more or an exciting effect on the transducer element.  But it gets more complicated than that.  later in time, the two primary modes should have for the most part group and phase velocity that is more or less constant with frequency for higher values of frequency * plate thickness.  But for lower values of frequency * thickness, these modes will show velocity varying with frequency.  Also, there is likely the presence of additional higher order modes creating further interference.

 

 

 

Now what this translates to as far as a math mode, well I am clueless and maybe this is far too complicated and / or not applicable for for curve fitting.....

 

 

Message Edited by DonRoth on 11-20-2008 06:46 PM
0 Kudos
Message 30 of 32
(3,165 Views)