Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: iterate over many inline functions?
Replies: 2   Last Post: Dec 13, 2012 11:08 AM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Paul Posts: 2 Registered: 12/12/12
iterate over many inline functions?
Posted: Dec 12, 2012 11:44 AM
 Plain Text Reply

Is there a way to group many inline functions into some single object so that I can then iterate over them? In my specific case, I have defined a set of 20 basis functions that I am using for a regression procedure. I've named the 20 inline functions like so:

phi1
phi2
...
phi20

Now I would like to specify that I actually want to use N basis functions for my regression and apply only those. So I'd like to gather my functions in some array-like object like this:

A=[phi1 phi2 phi3... phi20]

And apply a loop like this to calculate my design matrix:

x=set of data points
N=5
for i = 1:N
M=[M A(i)(x))]
end

so that if N=5 I'd end up with this matrix:

M=[phi1(x) phi2(x) phi3(x) phi4(x) phi5(x)]

I haven't found any way short of actually writing out by hand the functions to use for each case of N.

Date Subject Author
12/12/12 Paul
12/12/12 Steven Lord
12/13/12 Paul

© The Math Forum at NCTM 1994-2016. All Rights Reserved.