How can I store 'n' random transfer functions in a 1-D array fashion? (n =60 for example)
Show older comments
I am interested in storing n transfer functions and also be able to access these indices. I want to be able to access each of these TFs, that is the key! stack command in matlab could be helpful for my objective but I am struggling to make use of it within a for loop. Can some one help me with this? Thank you in advance!
1 Comment
jose tolentino
on 26 Oct 2019
how did you solve it?
Answers (1)
Geoff Hayes
on 6 Feb 2016
HP - why not use a cell array to store the transfer functions or the handles to the functions? For example, you could do something like
n = 2;
myFuncs = cell(n,1);
myFuncs{1} = @(x)sin(x);
myFuncs{2} = @(x)cos(x);
In the above, we have a cell array with two elements or handles to (anonymous) functions. We can access either as
myFuncs{1}(-pi/2)
ans =
-1
myFuncs{2}(-pi/2)
ans =
6.1232e-17
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!