help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Indexing functions?


From: Doug Stewart
Subject: Re: Indexing functions?
Date: Mon, 9 Oct 2017 08:00:35 -0400



On Mon, Oct 9, 2017 at 7:26 AM, denizyazgac <address@hidden> wrote:
Hi;
I have a function  depends on X and Y. I know X, thats an array so my
function only depends on X
But I want to create an "array of functions" which behave like

f(1)= Y*1^2
f(2)=Y*2^2
f(3)=Y*3^2
.
.
.
I should create different fuctions because every function will be
postprossesed different way in further.


clear
clc
x=1:1:10;
for index=1:1:length(x);
  f(index)=@(y) y*x(index).^2;
end

Is there a way to do this?




try this
clear

x=1:1:10;
for index=1:1:length(x);
  f(index)={@(y) y*x(index).^2};
end

feval(f{3}, 3 )



this is not your final answer but it is a start

reply via email to

[Prev in Thread] Current Thread [Next in Thread]