how do I store an array of functions?
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to store the following function for i=0:170
f = @(u) 2/(pi*sqrt(1-((sin(i/2)^2)*(sin(u)^2))));
and evaluate using my function.
1 Kommentar
Stephen23
am 8 Mai 2020
What is the point in creating 171 copies of (almost) the same function, when you can just create one?:
f = @(u,i) 2/(pi*sqrt(1-((sin(i/2)^2)*(sin(u)^2))));
Antworten (2)
per isakson
am 8 Mai 2020
Bearbeitet: per isakson
am 8 Mai 2020
An error message tells me
Nonscalar arrays of function handles are not allowed; use cell arrays instead.
Is this what are looking for?
>> f{1}(pi/2)
ans =
0.63662
>> f{100}(pi/2)
ans =
0.88291
>>
where f is created by
%%
f = cell( 1, 171 );
for ii = 0 : 170
f{ii+1} = @(u) 2/(pi*sqrt(1-((sin(ii/2)^2)*(sin(u)^2))));
end
Or why not
%%
f3 = @(u,jj) 2./(pi*sqrt(1-((sin(jj/2).^2).*(sin(u).^2))));
f3(pi/2,0)
0 Kommentare
KSSV
am 8 Mai 2020
i = 0:170 ;
f = @(u) 2./(pi*sqrt(1-((sin(i/2).^2).*(sin(u).^2))));
f = f(i) ;
plot(i,f)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!