LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

output from a for loop in mathscript

Solved!
Go to solution
Hello there! What I am trying to do is to produce a semi-circle pattern composed of separated rectangles using IMAQ DRAW, please see attached slide.
The pattern will be later projected on a screen. as the offset S changes, the number of rectangles changes. so I thought it would be easier using a for loop in mathscript, please see attached VI. but the problem is the outputs of the MATLAB script only store the last number it gets from the for loop. I tried to change the data type of the outputs into 1-D array, but it did not help either.
Could anybody please have a look at the VI and give me some suggestions? I have been stuck for days!
 
Thank you very much!
Brian
Download All
0 Kudos
Message 1 of 5
(3,357 Views)
Solution
Accepted by Raul6128

Hi,

 

I thought it would be easier using a for loop in mathscript

Why do you need a Mathscript node to calculate a simple circle?

Why not use basic LabVIEW code? Why not employ polymorphism to get rid of loops as much as possible?

 

check.png

(Just following the formulas given in your PDF. Because of square and root functions it will only work for one quadrant.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,342 Views)

Hi GerdW,

 

Thank you very much for your suggestion, it makes things much easier.

 

I 've only got one problem to fix. Since I need to project the pattern on a seperated computer screen, I guess I have to use the IMAQ DRAW function to implement it. but the problem is the data type of these two terminals are different.  The coordinate of IMAQ DRAW is 4 elements, and the outcome from the bundle cluster is 2 dimensions. Do you have any idea how to pass the data from the bundle to the IMAQ DRAW in 1-D array?

 

Many thanks!

Brian

Download All
0 Kudos
Message 3 of 5
(3,323 Views)

Hi Raul,

 

the problem is the data type of these two terminals are different.  The coordinate of IMAQ DRAW is 4 elements, and the outcome from the bundle cluster is 2 dimensions.

In my snippet I calculate the X and Y coordinates on the diameter of a circle. When you need more/other coordinates for IMAQ you need to calc them. Use my snippet as a starting point…

 

As I don't have IMAQ installed I cannot check what kind of data you need!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(3,318 Views)

Thanks! the problem has been solved.

 

Cheers,

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