Function handle
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi!
I need to create a cell containing a set of functions of ascending degree, that is: 1,x,x^2,...,x^n, to be used in another function. I have to transform the code:
fhandles = {@(x)ones(length(x),1), @(x)x, @(x)x.^2};
in a generic one where the degree is n (and not 2), where n is an input parameter of the main function. Can you please help me?
0 Commenti
Risposte (1)
Andrei Bobrov
il 20 Mag 2012
fhandles = @(n)cellfun(@str2func,cellstr(strcat('@(x)x.^',num2str((0:n)'))),'un',0)
0 Commenti
Vedere anche
Categorie
Scopri di più su Graphics Objects in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!