LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

linear fit

Hi guys, 

Attached you can find my project.

Now i need to determine the angular coefficient of the linear fit of 60 elements of the array named "Sforzi tarati" and i have to put all these angular coefficient into an array.

On the Y axis i want to have "sforzi tarati" and on the X axis i want to have numbers like 0, 50, 100, 150, ...

 

for example:

step #1 angular coefficient of the linear fit of the elements from #0 to #59 

step #2 angular coefficient of the linear fit of the element from #1 to #60

...

till the end of the array named "sforzi tarati".

 

someone can help me?

Thanks a lot

 

 

 

0 Kudos
Message 1 of 22
(2,386 Views)

It is very difficult to understand what you want to do.  It is also unclear what constitutes your data.  You talk about 60 elements of an array, but then mention "the angular coefficients of a linear fit" to these elements.  You didn't attach your data file, so we can't "guess" what you are trying to tell us.

 

Your VI shows that you don't know enough LabVIEW to do this yourself -- go spend more time with the Tutorials, ask your teacher for help, ask your classmates for help.  Some points:

  • You have a List Folder connected to your file path, but don't use its outputs.  So why is it there?
  • You read the same file twice, using Read Delimited Spreadsheet, but with different formats.  What are you trying to do?  I'm guessing (?) that the columns (or the rows) contain data in different formats.
  • If you need certain rows as numbers, but others as strings, a (logically) simpler way to do this is as follows:
    1. Read the entire file in as Delimited Spreadsheet with all elements being strings.  You should get a 2D Array of Strings.
    2. Isolate the Row(s) or Column(s) that has numeric data you want.  Pass this 1D Array through a For loop and convert the Strings to whatever numeric format you need.
  • The process you seem to be describing, namely fitting a straight line through the first 60 points, then sliding it over one point and doing the 60 points from the second to the 61, then sliding it over one point ..., does not make much sense to me.  Are you trying to do some type of filtering?  If so, use a filter.

Bob Schor

0 Kudos
Message 2 of 22
(2,365 Views)

(This is a VI, not a project. The term "project" has a special meaning in LabVIEW)

 

You did not include the data file. It would be simpler to just have the data in a diagram constant.

 

Your code makes no sense whatsoever.

  • Why would you use "list folder" if all you care about is the original path?
  • Why would you read the same file twice in parallel? It would be sufficient to read as strings and convert the string array to DBL. Same difference.
  • What is X and Y for the linear fit?

 


@Gquadro wrote:

for example:

step #1 angular coefficient of the linear fit of the elements from #0 to #59 

step #2 angular coefficient of the linear fit of the element from #1 to #60

 


You can use linear fit ptbypt with a sample length of 60.  But I would strongly recommend to start with a few basic tutorials first. 😉

0 Kudos
Message 3 of 22
(2,358 Views)

Hi guys, 

i know that the .vi is not well organized but for now is ok, i have to complete a work in labview but i don't have a lot of time so i'm soo sorry of this disaster.

Please forget about the .vi attached previously; we have to start from the array called "sforzi tarati".

 

i try to explain better what i need to do:

i have to do the linear fit of the elements contained in the array called "sforzi tarati" but not simultaneously of the whole numbers in the array but 60 elements per time. for each linear fit i have to calculate the slope and save all these slope in a new array.

 

 

 

0 Kudos
Message 4 of 22
(2,351 Views)

@Gquadro wrote:

 

Please forget about the .vi attached previously; we have to start from the array called "sforzi tarati".


 

As mentioned, we don't have your data and we have no idea how the values are arranged in it.

 

As attached, the "Sforzi tarati" in your VI is an empty array. If you want it to contain data, run your VI until it contains data, then "right-click...data operations...make current value default". Save and attach it once more.

0 Kudos
Message 5 of 22
(2,348 Views)

Here you

 

Thanks a lot

0 Kudos
Message 6 of 22
(2,342 Views)
0 Kudos
Message 7 of 22
(2,341 Views)

(Please don't attach a new file with the same name. If it is a different file, it should have a different name to avoid confusion. Since the name already existed, chrome renamed the new file to "Test1 (1).vi".)

 

Your file only has one column. I assume this is Y. To make a linear fit, you need X and Y. Is X just the array index or does it start over with each subset?

 

What is the result you want? How many elements in the expected result? N? N-60? N/60? Something else?

0 Kudos
Message 8 of 22
(2,325 Views)

See if this can give you some ideas....

 

altenbach_0-1580682323722.png

0 Kudos
Message 9 of 22
(2,319 Views)

 

 

 Sorry for the mistake with the file. 

 

As X you can use the index of the array. 

At the end I want to obtain the slope of each linear fit made on 60 elements. 

 

The first fit has to be done on the elements from #0 to #59

The second fit has to be done on the elements from #1 to #60 

... And so on till reaching the bottom of the array (always considering 60 elements, no more, no less) 

 

Your file only has one column. I assume this is Y. To make a linear fit, you need X and Y. Is X just the array index or does it start over with each subset?

I think that we should obtain something like n-60 elements 

 

 

0 Kudos
Message 10 of 22
(2,314 Views)