From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-02-2022 02:56 PM
Dear all community members,
I'm a new Labview user and I'm finding an issue difficult to understand for someone not very skilled... I've attached the main VIs I'm using.
I have to fit two sets of data with a phase modulated sine function, in particular one of the two signal is supposed to have a frequency which is twice the frequency of the other.
I've prepared a model function PM-sine-model which is written in the form f(t)=A+B*sin(C*t+D*cos(E*t+F)+G) which at a first step can be easily reduced to a sine function f(t)=A+B*sin(C*t+G) fixing D=0. I'm using this model with the Constrained non-linear fit VI sending for the two sets of data the time array, some guess parameters and also fixing some boundaries thanks to a pre-elaboration of the arrays of signals (envelope removed, average shifted to zero and amplitude normalized to +/-1): A is fixed to 0, B is fixed to 1, D at a first stage is fixed to 0 (and also E and F). Thus only C and G are the two free parameters for the optimization algorithm.
Unfortunately, even if the guess parameters provides two sine function which almost fit the data when the Fit button is pressed the Vi stops due to an error related to the singularity of the matrix difficult for me to understand.
Looking on other posts I've seen that this may be related to different scaling factors between the parameters, but I've already rescaled the time axis and normalized the datasets so the order of magnitude of the parameters is similar. Also I try starting with reasonable guess parameters and imposing reasonable boundaries to my opinion.
Do you have any suggestions?
If there is a "simple" error done by me I say sorry in advance!
Best regards.
03-02-2022 03:16 PM
03-02-2022 03:27 PM
Dear altenbach,
Thank you for your answer.
I've saved the VIs for previous versions (LV2012), are you able to open it now?
Best regards.
03-02-2022 03:37 PM
The model is still in 2021.
03-02-2022 03:44 PM
Sorry, try with the new uploade VIs.
03-03-2022 09:50 AM
Sorry, but one basic issue is that you don't even have a wait in your toplevel loop.
03-03-2022 11:22 AM
Dear altenbach,
-> You are right, I've added a "wait" in the loop.
-> The two original signals are two interferometric signal obtained from optical michelson interferometers at two different laser wavelengths, one the second harmonic of the first. They measure the same object displacement on the same time scale, thus as you supposed the next step should be to fit the two signals with a global fit imposing the constraint of the two frequencies (one to be twice the other). Actually, at a first stage I'm interessed in fitting with a "sinusoidal-like" function one of the signals. From basic theory an ideal interferometric signal is cosine function, but due to the moving mirror hysteresis it can be modeled as a phase-modulated cosine function (as you also noticed in your third point). So at the begininng I've implemented the model as a phase-modulated sine (switch it to a cosine seemed to me just a matter of phase shift). The thing is that even simplyfing the model making it a sine function fixing to zero the "central" parameters of the guess array the VI crashes or it stops to a local minimum, even if the central part of the signal if very close to a sine or cosine function. Any suggestions would be very helpful.
-> You are right, I've changed the costraints to +/- 2pi. Also on this side do you have any suggestions?
-> Is there an easy way to understand when the starting parameters are "good" to avoid stopping in a local minima?
-> Most probably there is a correlation between the parameters which makes the VI crash, but if the signal is close to a sine or cosine function and I use only two parameters (frequency and phase) of a sine function with a guess that seems "reasonable" it is difficult for me to understand why they should be correlated.
Otherwise, let's change the perspective of the problem: if you have to fit the same data of the VI knowing that they should be a "cosine" function probably modulated in phase or in frequency, how do you proceed? Is there a way to fit such data unambiguously?
Any suggestion is warmly welcome, even by changing the VIs themselves.
Thanks in advance.
03-08-2022 05:58 AM
Using linear sine fitting methods?
Search points: IEEE-STD-1057
P. Händel, Evaluation of a standardized sine wave fit algorithm, 2000 IEEE Nordic Signal Processing Symposium, Kolmården, Sweden, 13-15 June 2000, pp. 453-456, http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.35.3486
I found this one helpful:https://www.ippt.pan.pl/repository/open/o3063.pdf
I extended the matrix (14) to do a LMSE fit on n correlated frequencies in two (+x) channels