[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Vectorizing loops
From: |
andrewcd |
Subject: |
Re: Vectorizing loops |
Date: |
Sun, 6 Nov 2011 14:23:37 -0800 (PST) |
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.