LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem obtaining graph

Solved!
Go to solution
Hi all,
I have a problem with my VI. Please refer to attachment. I use it to read data from text file. However, it doesnt work when I want to show the graph of PAlpha and also PV. Please refer to case structure "Calculation of PV". Besides that, I expect to get a one dimension array for Mean of Pressure which is calculated under case structure of Select Pressure and Alpha.
Hope anybody could assist me to get the graph.

Attached together with this question are the VI, and also subVI.

Thank you and have a nice day. 
0 Kudos
Message 1 of 11
(3,330 Views)

I'm confused by your state machine. You start off in the "Write to file" state, which isn't actually writing anything - it's reading. The "Read from File" state doesn't read anything from file. It performs some calculations, and then goes to either the "Calculation of PV" state or it goes right back to itself ... performing the exact same calculations. Infinite loop here. The "Calculation of PV" state is where you are actually writing something to file.

 

I think you need to redesign your state machine. You should clearly delineate the function of each state, and have the state do what the state name says. Someone else looking at this code (like me) will have a hard time trying to understand the logic of it.

0 Kudos
Message 2 of 11
(3,322 Views)

Yeah, I realize the mistakes there. I will upload the new one.

 

Thanks.

0 Kudos
Message 3 of 11
(3,319 Views)

Hi Smercurio,

 

I already editted the VI for better understanding.

 

Please refer to attachment.

0 Kudos
Message 4 of 11
(3,311 Views)

Strange, in French forum same VIs not same person ? or same ?(EleveISAT)  not same question, seems to be exercices from school ? same strange state, to say exactly same.

 

Smiley Tongue

 

 

Greg S.
CNRS
LV 7.1 8.2 8.6 2009 2011 2012 2013 2014
LPMC - CNRS
N'oubliez pas de complimenter cela fait toujours plaisir.
0 Kudos
Message 5 of 11
(3,308 Views)
Can you also upload a sample text file that you read?
0 Kudos
Message 6 of 11
(3,307 Views)

Hi Gregory,

 

I'm working in a team. But my friend is french.

 

Please find attachment.

 

Thanks

Message Edited by Fird on 04-08-2009 10:02 AM
0 Kudos
Message 7 of 11
(3,299 Views)
 
0 Kudos
Message 8 of 11
(3,296 Views)
with your file your VI  stays in the case "select pressure and alpha" after in obtaining parameters i from you For will never be equal to 250 (for is for i=0 to N-1 or your N=250 so i will be 249), there is some bugs that think you should be able to correct if you use step by step debugging.
Greg S.
CNRS
LV 7.1 8.2 8.6 2009 2011 2012 2013 2014
LPMC - CNRS
N'oubliez pas de complimenter cela fait toujours plaisir.
0 Kudos
Message 9 of 11
(3,272 Views)
Solution
Accepted by topic author Fird

The above is indeed true. There are also a number of other issues with the code:

 

  • The specific comparison above is meaningless. The comparison will occur after the loops terminate, and the value of  the wire will always be the same, unless you change the number of iterations, which you are not. You are not stopping the for loop with a stop condition, so it will always run 250 times. What's the point of the comparison?
  • The attempt to delete the first row from the file that is being read is incorrect. You are wiring a zero to the length input.
  • The "Select Pressure and Alpha" state is getting chunks of 180 values. Unfortunately, you've read 10000 lines, but deleted one, which leaves you with 9999 lines (rows), which does not divide evenly with 180. 
  • The for-loop being used to create the 2D array of "Selected Pressure" and "Selected Alpha" can be done with a Reshape Array function.
  • The use of the Formula Express VI causes the unnecessary use of dynamic data. For example, in the "Calculation of PV" state (which is still writing to file), the Formula Express VI can be replaced with a simple Multiply primitive. Also, since the Build XY Graph Express VI is resetting the graph data each time you don't even need to use that Express VI. All you need is a single Bundle function. Doing those 2 simple changes allows you to delete all of the dynamic data conversion in that state. 


That's it for now. Smiley Wink

 

 

EDIT: Forgot one:

 

  • In the "Obtaining Parameters" state the for-loop has an uninitialized shift register. Not sure whether this is intentional or not, but I suspect it's an error. 
Message Edited by smercurio_fc on 04-08-2009 11:12 AM
Message 10 of 11
(3,251 Views)