From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mean on 3d Array in 3rd dimension and 3d arrays indexing in for loops

Solved!
Go to solution

I get it now. I still find it a shame the lack of certain functions in Labview.

0 Kudos
Message 11 of 19
(691 Views)

Hi Raphael,

 

I still find it a shame the lack of certain functions in Labview.

What exactly do you miss?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 19
(687 Views)

If you are comparing LabVIEW to Matlab, a purely mathematical application, then yes LabVIEW will not live up to your expectations because LabVIEW was not written as a replacement for Matlab.   There is integration between LabVIEW and Matlab if that is something you are interested in.  However, the basic tools are available to you as the developer to make your own functions (subVIs), ones that Matlab may have available as standard but are not currently found in LabVIEW, such as taking a mean in the 3rd dimension.  There are toolkits available on VIPM that others have developed to provide additional functionality and I would encourage you to go check that out. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 13 of 19
(680 Views)

@RaphaelMT wrote:

 I'm use in Matlab to avoid loops. I fear that the process will be extensively slowed down by them.


That's the silliest thing I heard in less than a week. Why would a FOR loop slow down anything? Do you really believe that Matlab can magically operate on thousands of values in parallel just because you don't see a loop??? 😮

 

For more discusssions, have a look at my recent post here. Still applies.

 

 


@RaphaelMT wrote:

That is the wrong direction. I don't want the mean of the row or column but of the depth. I want to go from a 1000x1000x3 matrix to a 1000x1000 one.


That's exactly what my code does! Have you even tried???

0 Kudos
Message 14 of 19
(673 Views)

Ii most likely as to do on how Matlab interpret the code you've written. For exemple, for two arrays the same size you are trying to multply each element by each other you could write it in these two ways:

1. Everything at the same time

A.*B

2. Or row by row

for n = 1:length(A(1,:))

A(n,:).*B(n,:)

end

In the end it's the same computation and should be the same amount of parallelism but the first option takes half the time in Matlab.

0 Kudos
Message 15 of 19
(655 Views)

@RaphaelMT wrote:

In the end it's the same computation and should be the same amount of parallelism but the first option takes half the time in Matlab.


If that bothers you, post it in the Matlab forum. It has no relationship with LabVIEW and FOR loops there. Have you compared LabVIEW with Matlab? That's all that matters. Also be aware that benchmarking is more art than science and is difficult to get right in either environment.

0 Kudos
Message 16 of 19
(651 Views)

I just wanted to explain you my hesitation toward loops in general. If it's different in labview, that's great. I'll do more testing to see how it performs.

0 Kudos
Message 17 of 19
(646 Views)

I don't understand why you are trying to code a LabVIEW solution in Matlab if Matlab already has the functionality available "without using loops" as you say.  This whole thread is not making any sense to me.  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 18 of 19
(637 Views)

@RaphaelMT wrote:

In the end it's the same computation and should be the same amount of parallelism but the first option takes half the time in Matlab.


And with a better compiler implementation, both code fragments could turn into identical binary code. Matlab decided not to do that and they probably have a good reason, such as the the ability to debug. These are very complex decisions. Most algorithms can be written in many ways in either environment and it is up to the programmer to decide if performance of a particular code fragment really is the bottleneck. Most of the time it isn't. It isn't worth spending days to shave off a nanosecond.

0 Kudos
Message 19 of 19
(636 Views)