07-11-2024 03:24 PM
Hi all,
I'm a bit of LabView novice but am having trouble with this likely not too challenging scenario. A picture of the code and the raw signal is attached. Essentially, I want to calculate the initial slope and the 500 ms rolling average peak for each of the plateaus. With my current code, I'm only getting the value for the first plateau for each array output. I'm not sure if my for loop within for loop approach is the issue or something about the code inside. Any assistance would be greatly appreciated.
Solved! Go to Solution.
07-11-2024 04:19 PM - edited 07-11-2024 04:21 PM
We typically don't debug images, but this code really has some bad smell. Have you done any tutorials?
Please attach your VI (save for previous, 2020 or below) and make sure all controls have typical default values. Also include a dataset, unless the 1D array coming in from the left has a control with useful default data. Explain exactly what the code should do.
07-11-2024 08:20 PM
I've done tutorials but my needs don't normally require customizing code so hence my status. Appreciate your input. See the code attached. The data file is too large unfortunately but the raw signal image exhibits its nature. It's muscle force data and I want to calculate the upward slope of each curve (aka RTD) started at 2.5 Nm until 200 ms later. Then, I want the peak 500 ms rolling average (aka PT) for each plateau. Point taken about the for loop with an iteration of 1 being pointless. When I delete it and only have the one for loop with 18 iterations I get the same result which is the RTD and PT data for the first plateau only for all iterations. Not sure what I'm missing to get RTD and PT data for each plateau.
07-12-2024 02:03 AM - edited 07-12-2024 02:04 AM
Hi ghester,
@ghester wrote:
I've done tutorials but my needs don't normally require customizing code so hence my status. Appreciate your input. See the code attached. The data file is too large unfortunately but the raw signal image exhibits its nature. It's muscle force data and I want to calculate the upward slope of each curve (aka RTD) started at 2.5 Nm until 200 ms later. Then, I want the peak 500 ms rolling average (aka PT) for each plateau. Point taken about the for loop with an iteration of 1 being pointless. When I delete it and only have the one for loop with 18 iterations I get the same result which is the RTD and PT data for the first plateau only for all iterations. Not sure what I'm missing to get RTD and PT data for each plateau.
I did some simplifications to your VI:
(There still is room for more simplifications.)
Your FOR loop running 26 times still doesn't make any sense you you simple do the very same calculation again and again: what is YOUR reason for this loop?
07-12-2024 08:28 AM
I will give this a try, and thank you! You are correct that I need the same calculations to be performed for each plateau (let's say 26 times for this example). I was under the impression the for loop is the tool for doing consecutive calculations across sections of samples (each progressive plateau).
07-12-2024 09:37 AM - edited 07-12-2024 09:39 AM
You failed to attach your datafile, so we cannot test. Please attach it!
How regular are the gaps and plateaus in terms of spacing?
07-12-2024 10:02 AM
My original data file was too large so I've attached a cut down data file that only has 3 of the plateaus. I don't doubt there are many aspects that could be improved or refined, but my main issue is performing the two calculations (PT and RTD) for successive plateaus. The program generally does what I need it to, reads torque column --->scales torque-->and calculates PT and RTD but only for the first plateau as it is. I just don't know how to have it done for each plateau. Noise is reasonable. Spacing is quite consistent (5 sec between plateaus) and the 2.5 Nm threshold is being used as the "indicator" of a new plateau.
07-12-2024 11:43 AM
Why would you attach an xlsx file (Microsoft binary file) if you try to read it as comma delimited csv file?
You need to simply keep track of the processing point and continue from there.
So let me clarify:
This all seems trivial to do, let me try later...
07-12-2024 12:26 PM
Hopefully, my clarifications for each bullet are helpful.
07-12-2024 12:49 PM
See if this can give you some ideas. (Currently not doing the max of the rolling average, so implement that if needed.