LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

data displayed from a spreadsheet not correctly

Solved!
Go to solution

Hello,

I'm trying to read the content of a spreadsheet (matlab variable) in labview using read from speardsheet VI.But the problem is that when i display the data (using the polymorphic VI double) I get an array containing 2, 1 etc.. but the correct values should be 0.026855000000000 (via Matlab)..

I'm using this data as an input for a matlab algorithm (.m file using matlab script) , since i get a different result implementing the same .m file and input in using labview than using matlab, i thought that maybe the problem is the input data..
Here is the code

0 Kudos
Message 1 of 13
(6,033 Views)

Try to use %f instead of %d (%d is for signed integers)

 

(...or just leave the format and # of rows unwired. The defaults are OK!)

0 Kudos
Message 2 of 13
(6,015 Views)

If you need more detailed help, attach the data file (or a smaller version of it) and the actual VI.

Message 3 of 13
(6,013 Views)

Pictures are pretty useless -- we cannot "inspect" them, we cannot "execute" them, and they are frequently "incomplete" (a small piece of the puzzle).  I'm sure there is a problem in your code, but would need to see your code, so attach your VI.  Also, since the problem involves reading and parsing a data file, attach an example of the data file.  With these two things to guide us, you should get a quick (and correct) response.

 

Bob Schor

 

Note that Altenbach just said this -- I'm just a poor echo ...

Message 4 of 13
(5,984 Views)

Hi there, thanks for your replies .. Okay I attached two files (Matlab variables saved as ASCII) that I want to load to the VI and get the correct classification (i.e: h1_Healthy as (in french) healthy gears, healthy bearings, healthy shaft (engrenages sains, roulements sains et arbres de rotation saines ) and h4_Healthy_F_F as Healthy gear, faulty bearing and faulty shaft (engrenages sains, roulements defectueux et arbres de rotation defectueuses) ) ..
For your information, the VI contains the MATLAB script of some classifiers (3) that predict the class of 3 component of a gearbox (gears, bearings and shaft). And since the data that they (classifiers) learned on are the same I'm trying to load, the percent of prediction should be 100% for every correct class, the problem is for gears the percent of the correct classification is only 66% meaning that one classifier thought that the gear is faulty (for h1_Healthy) .., you can see the same problem for the second variable..
I hope this time the idea is clearer..Thank you for your time and consideration.

The reason why I didn't want to put up the vi and all, because it wouldn't work on your computers because it needs so many things like other variables, modules and most of all MATLAB installed..

Thank you for your time and consideration.

 

Download All
0 Kudos
Message 5 of 13
(5,960 Views)

Your problem is that each line in the file contains extra speaces, 

 

All you need is "read lines" (see details here), then convert to DBL, e.g. as follows.

 

 

 

 

(You ave many very questionable code constructs, for example:

None of your value proerty nodes (bottom left of diagram) are needed, just configure the VI to clear indicator when called (execution option). Your property nodes also execute in parallel to the writing to the indicators, thus you can have a race condition and whatever writes last wins. You don't guarantee that the real data writes last.. I am sure you "pyramid" of case structures could be eliminated completely. Try to avoid overlapping and hidden wires. You string concatenation could be replaced by a simple formatting operation. Your little FOR loop does not do autoindexing on the output, thus all you get is the last value, a 2D array with a single element. etc.)

 

Message 6 of 13
(5,936 Views)

Hi there,

Thank you for your reply, I have tried using the VIs you told me, but I still get one value (2) instead of an array of numvers like 0.002458  etc..

Concerning the other hint you gave me, I'll try to implement them to have a cleaner code.. thanks !

I should tell you that the file i'm trying to import was exported from matlab using the function save ... ascii

0 Kudos
Message 7 of 13
(5,924 Views)

Then show us your new code. Did you really wire a -1 to the number of lines as shown? Did you right-click the file read to "read lines"?

What language is your OS? Does it use e.g. comma as decimal delimiter?

0 Kudos
Message 8 of 13
(5,921 Views)

Yes i did... the output of the read lines VI is a scalar..

0 Kudos
Message 9 of 13
(5,916 Views)

@remapears wrote:

Yes i did... the output of the read lines VI is a scalar..


No, you did not! See the different look of the file IO?

 

You need to right-click the file read and select "read lines".!

 

(currently you are reading the file a a single long scalar string. Once you read lines, you get an array of strings, one element per line)

 

Message 10 of 13
(5,913 Views)