05-08-2009 03:00 AM
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.
05-08-2009 09:45 AM
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.
05-08-2009 09:59 AM
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.
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.
05-08-2009 12:58 PM
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?
05-08-2009 01:11 PM
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?
05-09-2009 07:13 AM
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
05-09-2009 11:15 AM
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: