arctica1963 |
Hello all,
I know this topic has been touched on before: Efficient calculation for a moving window <http://mailinglists.scilab.org/efficient-calculation-for-a-moving-window-td4035997.html#a4036023> I am looking at running a moving window over a grid, incrementally shifting along rows and columns, to allow processing within a window, with output appended to a file (e.g. some mathematical function) Can the code below be adapted for such processing: // START OF CODE n = 100; m = 20; // moving window size function y=f(x) // function f can be anything but must operate on columns of input x y = mean(x,'c'); endfunction // Initial loop solution: y = rand(1,n); y1 = zeros(1,n-m+1); for i=1:n-m+1 y1(i)=f(y(i:i-1+m)); end // Optimized solution with vectorization: [X,Y] = meshgrid(1:m,1:n-m+1); y2 = f(matrix(y(X+Y-1),n-m+1,m)); printf("difference = %g\n",norm(y1-y2')) // END OF CODE I have a grid with has nx_cols=120 and ny_rows=120, and I want to run say a 10x10 window, shifting 5 units (rows and columns for overlaps) over the whole grid and calculate within each window. I am assuming that one has to do this via indexing rows and columns respectively. Hopefully this can be clarified. Sorry if this is a very basic query! Thanks Lester -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
What type of function you need to evaluate at each patch?
How long does it take to run with the simplest double-loop implementation? Your problem seems to have only 24 x 24 = 576 iterations ... _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Hi Rafael,
At the moment I am just looking to get a general methodology/script to test. The real data grid is more like 1500x1500 or more. The function could be anything really (e.g. z=f(x,y)), but ultimately I am looking to run a radial averaged PSD from which one can extract depth to magnetic sources (that's another story as they say!). Not sure if that is any clearer. As I say, just looking for a general structure to test, before jumping ahead. I'm guessing it needs a nested for loop for rows and columns? -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Hi Lester,
Without further information, the simplest approach would be to write two nested loops. Now, regarding the computation of radially averaged PSDs, you may want to take a look in the web for published code. For example, look at the function raPsd2d, written by Ruzanski (2009) for Matlab. Regards, Rafael _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Hi Rafael, On 19:34, Fri, 3 Aug 2018 Rafael Guerra, <[hidden email]> wrote: Hi Lester, _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users |
Free forum by Nabble | Edit this page |