LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Make a real--time plot of the linear fit calculated

Solved!
Go to solution

Hi, here it's how my program worked:

 

1) Plot some data read from a file

2) Lets user to move cursors to select a range of data

3) Lets users to choose Y-Scale with 2 control (Y minimum and maximum)

4) Make a real-time linear fit of selected data and gives results.

 

And here no problem, i putted the xy graph out of a while loop in wich i putted

1) the fitting function (selecting data with 2 locals variable (cursors) and some array-function)

2) 2 local variable (write) to adjust Y-scale with the number into control.

 

User move cursors and data appear, all right.

 

The problem is that i want to draw the fitted line on the xy-graph, so i made 2 x 2-number-array (with x = 0,1 and y = intercept, slope +intercept) and ...

 

i must plot xy-graph in real-time to make that the fitting line refresh on a cursor move XD

 

So i putted the graph into the while, and i plotted it every time the while cycle (i used a condition with shift register to jump useless computing).

 

And here the problem: when the xygraph is plotted the Y-scale is the default one. Few ms next the Y-scale will go correct (when the program set the y scale to the value of controls).

 

Is there a way to avoid that the graph will go to the default scale when it's plotted again? Or is there a way to plot the fitting line without plotting all the xy graph?

 

thanks

 

PS: i tryed to put a stacked sequence with 1) paint the graph 2) adjust the scale but you cen see in any case the flash of the uncorrect Y scale

0 Kudos
Message 1 of 8
(3,703 Views)

We are graphical programmers, so please attach a simplified example of your VI. It is impossible to reconstruct what you are doing from your description.

 

(I always get a headache if I read local variable and stacked sequence too many times 🐵

0 Kudos
Message 2 of 8
(3,691 Views)

Here is an old example that might give you some ideas (look at the lower graph). (posted originally here)

0 Kudos
Message 3 of 8
(3,689 Views)

sorry for my bad english, here a png with the interested part of code:

 

Immagine.png

 

as written on the 1st post now graph is into while, so it's refreshed every cycle. But the Y scale go to the default value when the graph is plotted, and next it is setted to the control value (n°1 in stacked sequence).

 

But i still see the flash of the default scaled graph (for few ms every time i move the cursor)

 

Sorry for confused code but it's my 1st one.

 

0 Kudos
Message 4 of 8
(3,684 Views)

We really need to see the actual VI, not a picture of the diagram.

 

 


@brazoayeye wrote:

 

as written on the 1st post now graph is into while, so it's refreshed every cycle. But the Y scale go to the default value when the graph is plotted, and next it is setted to the control value (n°1 in stacked sequence).


 

What do you mean by "default value"?

What is in frame 0 of the stacked sequence?

 

Overall, there is a lot of unreadable code with many overly complicated constructs. For example your small case structure could be replaced by the Max&Min function.

0 Kudos
Message 5 of 8
(3,680 Views)

here the vi that give the "problem". The macro will not work because there aren't the subvi i used (do you need them too?)

 

I means that if i scale from 0 to 1 (on Y) when i move the cursors i can see for few time points on range 0-10 (i can't see the max value).

 

The stack 0 is the shown, the 1 is an assign of Y min - max (as above).

 

I used that costruct because it seems more performant (plz tell me if it's not so).

 

If you can tell me where i could use more appropriate function i'll be grateful.

 

Is there another way to plot the linear results without painting all the graph every time

 

 

0 Kudos
Message 6 of 8
(3,677 Views)
Solution
Accepted by topic author brazoayeye

I think all you need to do is turn off autoscale for the axes. 😄

 

Overall, there are some very convoluted and very dangerous code constructs. Here's a small sampling (there are many, many more!):

 

The code on the left can lockup the program, for example if the data is all zero. Why is there a local variable? just wire from the source, it's right there! What you probably want instead of these small while loops is the threshold array function. No loop needed.

 

To write two properties, you use four(!) property nodes and three deeply stacked sequence structures. Property nodes execute top to bottom, so all you need is the code shown below! Also note that "index array" is resizeable. You don't need to wire the index unless you want something special.

 

 

 

0 Kudos
Message 7 of 8
(3,666 Views)

 


altenbach ha scritto:

The code on the left can lockup the program, for example if the data is all zero. Why is there a local variable? just wire from the source, it's right there! What you probably want instead of these small while loops is the threshold array function. No loop needed.

 


 

 

I don't know how that function works inside, and it seems more than what i need. In any case i give data for my analysis (i want to analyze data in that range)

 

 


 

To write two properties, you use four(!) property nodes and three deeply stacked sequence structures. Property nodes execute top to bottom, so all you need is the code shown below! Also note that "index array" is resizeable. You don't need to wire the index unless you want something special.


Thanks, i didn't see index was resizable. I thought that all was data-flow controlled, now all seems easier 🙂

 

For local variable, can't i use them to avoid to have lots of wire around the code? is it worse?

 

thanks for help!

0 Kudos
Message 8 of 8
(3,658 Views)