[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Vectorizing loops
From: |
Juan Pablo Carbajal |
Subject: |
Re: Vectorizing loops |
Date: |
Mon, 7 Nov 2011 06:14:57 +0100 |
On Sun, Nov 6, 2011 at 11:23 PM, andrewcd <address@hidden> wrote:
> Thanks all for the help! Without your comments, I wouldn't have easily found
> the "reshape" function, or the "repmat" function -- its difficult to google
> a bunch of poorly-worded desires.
>
> For my second problem, I discovered that what I wanted to do was called
> "interpolation", and that there are functions for that.
>
> These are the perils of teaching things to yourself -- you do things the
> hard way for a while before you learn the easy way.
>
> For posterity, my working, quick code for making the time series maps into a
> panel dataset is:
>
> x = x_NDVI'; %X coordinates
> y = y_NDVI; %Y coordinates
> t = 1:size(P_int,3); t=t' %Time
>
> a = x*ones(1,length(y)*length(t));
> a = a';
> Q(:,1) = reshape(a, length(x)*length(y)*length(t),1);
> a = y*ones(1,length(t));
> a = a';
> a = reshape(a,length(y)*length(t),1);
> Q(:,2) = repmat (a, length(x),1);
> Q(:,3) = repmat (t, length(y)*length(x), 1);
> Q(:,4) = reshape(N, length(x)*length(y)*length(t),1);
> Q(:,5) = reshape(P_int, length(x)*length(y)*length(t),1);
>
> --
> View this message in context:
> http://octave.1599824.n4.nabble.com/Vectorizing-loops-tp3992596p3996951.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
Hi,
I do not know if you got further with the interpolation problem.
Octave has a wide set of functions, most of them start with "interp".
So, type "interp" (without quotes) in your octave terminal and press
tab to see the suggestions. Also, there is a package in Octave-forge
about optimal interpolation (optim-interp).
What you said about keywords is a very important insight, have it
always in mind.
http://www.science3point0.com/cienciajpscience/2011/08/15/open-question/
--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/