LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mathscript Error Using strcmp with Cell Data

I am using LabVIEW 2013 and am trying to incorporate some Matlab code a colleague wrote. I kept running into a problem in one section, and have been able to reproduce the issue.

 

I am using Cell data to store an array of valid, variable length strings.  When I try to pick one of the strings, and compare it to another string, the Mathscript node gives me an error (see below):

 

StrcmpError.PNG

 

Whereas the following code works just fine:

 

StrcmpOK.PNG

Is this expected behavior because of using cell data?  Is there a way to work around this?

 

Thanks for your help.

 

0 Kudos
Message 1 of 5
(3,307 Views)

Hi

 

Try to change brackets like on example below

 

strcmp.png

 

Regards

0 Kudos
Message 2 of 5
(3,274 Views)

I strongly recommend doing everything in LabVIEW (string arrays are easy) or everything in MatLab.  Mixing the two languages gives you opportunities for errors in both.  You are missing the commas between the array elements in your first line of Matlab code.

 

BS

0 Kudos
Message 3 of 5
(3,252 Views)

Adding to Bob's post, that's an incredibly easy piece of code to translate into LabVIEW.  I trust your colleague's matlab code is a bit more advanced.  But, you'll find there's some overhead related to adding an extra compilation task there.  If performance is at all a concern for you, you'll want to convert the code into LabVIEW and then move forward.  If that's not an option, you should consider the option of developing their code instead.  If you can't develop matlab, their code will be something you can't modify going forward.  Why would you want to add a block to your code that you can't modify?

0 Kudos
Message 4 of 5
(3,223 Views)

Thank you all for the solution and advice.

 

The posted code was an example that attempted to reproduce the error I was seeing (and fortunately it worked).  Interestingly, the code works without the commas in Matlab.  The actual code is hundreds of lines long, and I've worked through some other errors, but had no idea on this one.

 

I would much rather convert the code, but I don't get to make the decision in this case.

 

 

0 Kudos
Message 5 of 5
(3,181 Views)