Multiplying anonymous function by a vector
Afficher commentaires plus anciens
I'm trying to plot 4 different graphs in respect to 4 different function handles for 10 revolutions using for loop. I've created a function file and a m-file but the error Operator '.*' is not supported for operands of type 'cell' just keeps popping out.
%% Function file
function [x,y] = my_polar(fhandle, N)
th = 0:0.01:2*pi;
for i =0:N-1
x = fhandle.*cos(th);
y = fhandle.*sin(th);
th = th+2*pi;
end
end
%% m-file
f1 = @(th) exp(0.01*th).*sin(5*th);
f2 = @(th) sin(10*th) + 0.15;
f3 = @(th) sin(0.5*th).*(0.85 + sin(th));
f4 = @(th) 10 + sin(2*pi.*th);
fset = {f1;f2;f3;f4};
for i=1:4
subplot(2,2,i);
[x,y] = my_polar(fset(i), 10);
plot(x,y);
title(char(fset(i)));
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!