LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab for cycle in labview

Hello,

 

I have tryed to implement matlabscript into the labview, but  without success. I am loading data from spredsheet file and than trying to transform some vylues for one graph. (In attachment data file and also VI). Thank you for help.

Download All
0 Kudos
Message 1 of 7
(3,699 Views)

Hi kbx,

 

Thanks for the post and I hope your well today.

 

What exactly doesn't work for you? Do you not get the data from the file? Do you get an error from the script node?

 

At the bottom right of the node there is an error out terminal - this will tell you more details about any errors from within the script.

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 2 of 7
(3,671 Views)

Well, I can see that your program is growing. It's good to see you're making headway with it. The wiring is still a bit sloppy, though. Smiley Very Happy

 

Are you sure you're reading the correct file? For that part you need to read one of the files in the "all" directory. The front panel control has a default value set up to read from the "calibrated" folder, and those files don't have enough columns, so in those cases you are feeding an empty array into the Matlab node. 

Message 3 of 7
(3,666 Views)

Hi,

 

thank you for reply. I didn´t know if I could write about the matlab problem in the same topic so a I made a new one. But my programme don´t grow so much. That is still testing version. I am trying to transforme the weird graph  by the help of matlab skript, but still have some problems. I uploaded wrong .txt file but it doesn´t work even with the right one.Could I fix it?

0 Kudos
Message 4 of 7
(3,650 Views)

kbx wrote:

Could I fix it?


Probably, but we first need to understand what's wrong. You said previously "without success". In the follow-up you said it "doesn't work". As James indicated, what does this mean? Do you get an error? Wrong data? If so, where?

0 Kudos
Message 5 of 7
(3,643 Views)

Ok,

 

I will try to specify it again. I have too main problems. One is about the problem which we wrote before and one is new.

 

1. NEW one (File:loadandfor.vi , source file: MT_00323270_000-00.txt):

 

a)Trying to load from spreadsheet file MT_00323270_000-00.txt, but no numbers are loaded.

b)I need to load first col. .. this is acceleration. I need to recalculate it to velocity and trail according to relation --> v=v0 + acc/64; s=s0+v/6.Probably for loop is necassary,because in Matlab the script is:

 

sz=size(accp);
v = zeros(size(accp));

for j=2:sz(1)
   v(j,:) = v(j-1,:) + accp(j,:)*1/64;
end

 

But solve this problem without using matlab code will be great or do the same procedure only with labview tools.

 

 

2.Old one (File:matlabimplement.vi , source file: MT_00323272_zada.txt):

I have loaded data successflly and now need to transform curve of yaw. I know only how to write it in Matlab, but solve it without using Matlab script will be great.

Matlab script is:

ot = rpy(:,3); %loading of yaw data

l = length(ot);
p = zeros(l,1);
p = ot(1);
for k = 2:l
    if ( (ot(k) - p(k-1)) > 180)
        p(k) = ot(k) - 360;
    elseif  (ot(k) - p(k-1)) < -180
        p(k) = ot(k) + 360;
    else
        p(k) = ot(k);
    end
end

 

Thanks

Download All
0 Kudos
Message 6 of 7
(3,625 Views)

For loadandfor.vi:

a) The reason for this is that your numeric formatting is different with the file you attached. In this one a comma is being used as the decimal point. In your previous files a period was used. Did you change something with your operating system, or were the files generated differently?

b) That operation can indeed be done in LabVIEW. You can use a for-loop with a shift register to keep track of v. The Initialize Array function will allow you to pre-allocate v based on the length of accp. 

 

For  matlabimplement.vi:

Same comment as before. That Matlab code can be implemented in LabVIEW and will be WAY faster. It seems to me that your fundamental problem is lack of understanding of dealing with arrays and loops. I would suggest spending some time familiaring yourself with how to do array operations such as indexing, and replacing elements, as well as initializing arrays. Also spend time on using for-loops, especially on how to auto-index them from arrays. A Shift register is a powerful tool. Read about and you will see that you can implement your Matlab code using them.

 

Other comments:

  • You really need to provide a prompt for your file dialog functions. You have no way of knowing which dialog will run first, so the user has no way of knowing which file is supposed to be selected.
  • The header rows have already been removed when getting accX, accY, and accZ. You do not need to perform the same operation again. This simply creates a duplicate of your data. Learn to branch wires.
  • You're already indexing out accX, accY, and accZ. All you need to do is to resize Index Array to pull off column 13. Wait, now that I look at the code I see another problem. The Index Array function for accX, accY, and accZ has 4 indexing terminals. You've wired a constant to the 1st, 2nd, and 4th. As it is, subsequent indexing terminals are automatically increased by 1 (so you can delete the constant of 3 and 4) so this bug is inconsequential since the 3rd terminal will pull off column 4.
0 Kudos
Message 7 of 7
(3,609 Views)