12-17-2023 11:54 PM
Hello all,
I want to smooth a signal in real-time using Gaussian smoothing and convolution functions. First I did it in MATLAB as a post-processing for smoothing the data, but whenever I try to implement it in Mathscript or the formula node of Labview for realtime processing it continuously gives error and does not working. For reference, I have attached the MATLAB code.
Any help will be appreciated.
Regards,
Ronak
12-18-2023 01:02 AM - edited 12-18-2023 01:06 AM
Hi Ronak,
ronakvyas971@gmail.com wrote:
whenever I try to implement it in Mathscript or the formula node of Labview for realtime processing it continuously gives error and does not working.
Why do you try to use MathScript or the formula node?
Which errors do you get?
Why not use "real" LabVIEW?
(Please check for correct execution, my Matlab is a bit rusty… Accidently set sigma to 100 instead of 10.)
Hint: There also is a convolution function in the SignalOperations functions palette!
12-18-2023 01:16 AM
Hey,
Thanks, for the quick response. I saw your LabView code and will try to implement it in my VI. The reason for utilizing math script is that I never utilized the Gaussian Function in Labview. So, I went for Mathscript or Formulanode. The main reason behind doing this process is I have my force signal and want to convert that into the smooth exponential signal with smooth increase and decrease signal that corresponds to my original signal with the same amplitude. So, to perform that I choose mathscript. I have also attached my force signal (original) and the required signal (smooth) picture, which did in Matlab.
However, the VI you made, there is not have any information about convolution.
It would be great if you could help me to get over this.
12-18-2023 02:53 AM
There is a Convolution.vi already implemented in LabVIEW, you might want to try that.
12-18-2023 10:33 AM
ronakvyas971@gmail.com wrote:
I want to smooth a signal in real-time using Gaussian smoothing and convolution functions.
First you need to define your use of the word "real-time", because it can have very specific meaning.
If your data arrives one point at a time and you want to smooth, you need would need to use the ptbypt convolution function (I have not tried it). If it is just about getting rid of noise, there are plenty of other ptbypt filters you could try.
A very lightweight filter for realtime data is an exponential filter, which often works great.
12-18-2023 10:38 AM
ronakvyas971@gmail.com wrote:
It would be great if you could help me to get over this.
Obviously, you cannot get that red result in "realtime" because the red curve requires future data (e.g. it rises before the blue curve rises!), so this kind of analysis can only be done with a significant time delay (or in post processing).
As a first step, explain the experiment and how much data you get as a function of time and what you want to see during acquisition.
It would be easiest to attach a Vi containing some sample data.
12-18-2023 10:59 AM
Hey,
Thank you for looking into this. For your reference, I have attached the sample data file in that DFP column data will come in real-time, which is a force signal coming from the motor and is not in proper form like a bell-shaped curve. From that signal, I have to control some devices for that the force signal needs to be in proper form like bell shape curve or smooth. But the signal that I'm getting is in a kind of square signal with sudden increase and decrease, but I want to smooth it. For the first, I went for that gaussian function with kernel, and I'm still trying to fit it in LabView. However, all these operations will need to be performed in real-time. For your reference, I have attached the some sample data. The VI is same as I mentioned for the first time, and I wrote that whole Matlab code in the math script of Labview. Hope to hear soon.
12-18-2023 11:07 AM - edited 12-18-2023 11:11 AM
@GerdW wrote:
Also note that that entire division business (and sqrt, time pi, etc) is completely pointless if we later divide by the sum, of course. (not blaming Gerd here, it's just a literal translation of the original text code). Also, the "negate" should be done on the scalar, not on the array, of course)
12-18-2023 12:11 PM - edited 12-18-2023 01:00 PM
See if this can give you some ideas. Probably needs a few tweaks...
Note that that size=x option is only available for 2D convolutions for some unknown reason reason)