IdentifySecPropagateSubfunction -?



Howdy again all,

I was looking at the MeasureRadialDistribution module and trying to figure out the components. Could anyone let me know what IdentifySecPropagateSubfunction does? How do I edit it? What’s the CPP file and what’s the MEX** file? Sorry to be a bother. I’m obviously not great on this end of things.




So I finally figured out what the output is supposed to be although not necessarily how it does it (which at this point isn’t totally important), nor why it does it through the CPP instead of .m (which I’m sort of curious about, but is also not terribly important). My new question about the MeasureRadialDistribution is how the full(sparse command gets the data to collapse down and sum up all the intensity values. That’s all in all quite cool but slightly mysterious to me…



Hi Peter,

To address your first point: There are some operations which MATLAB does extremely quickly but others where it’s actually quite slow. To perform these slower operations, we write the code in C++ instead of MATLAB to make it faster. The .cpp file is the C++ code and the MEX file is the compiled .cpp code that MeasureRadialDistribution interfaces with.

Re: sparse command - A sparse matrix is a data structure used for efficient storage of matrices when most of the elements are zero. The nature of these structures is that duplicate elements are added together, which is helpful for the computational problems for which they are commonly used. So if applied properly, they provide a useful means of adding values together very quickly. See here for more on this.



Thanks again for the help. That was extremely useful. This may not be the right place for it, but how do you decide when it’s more worthwhile to make a MEX file and when to let Matlab handle things? How do you make an MEX file? Is there a website covering these types of topics?




Sorry, one thing that came to mind: why not use accumarray? Is it as faster than full(sparse as it claims?


In general, MATLAB is very quick performing operations that can be “vectorized.” So (for example), if you want to add two matrices A and B, the standard procedure is to loop through the elements and add A(i,j) to B(i,j) to get your result. This can be time-consuming, but MATLAB lets you do it with the simple command A+B. If the operation you want can be reduced to this form, or some variant of it, a MATLAB M-file script or function is the way to go.

However, if this not doable and you can’t avoid using loops, MATLAB gets really slow and it may be better for a MEX file to handle it.

You can look here for more info.



I’d take MATLAB at it’s word that accumarray is quicker. We just haven’t updated the code for that function accordingly yet :wink: