How do I graph a function handler(h_func=@(a,b),where a=10cos(x), and b=5sin(x)) that has other function handlers inside the function?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm having problems graphing this program, that consists of three anonymous functions. The object is too create three anonymous functions, with the third h_func=@(a,b)sqrt(a^2+b^2) and graph it over a range of -10<x<10 with a seperate plotFunc function. These are the three functions so far;
cos_funct=@(x)10*cos(x);
sin_funct=@(x)5*sin(x);
h_funct= @(x)sqrt((sin_funct.^2)+(cos_funct.^2));\
This is the plotFunc function that I am supposed to use to plot (h_funct) function plotFunc( fun,points )
fname=func2str(fun);
hold on;
plot(points,fun(points));
title(['\bfPlot of ' fname '(x) vs x']);
xlabel('\bfx');
ylabel(['\bf' fname '(x)']);
grid on;
end\
My problem is that whenever I call plotFunc(h_func,[-10:10]) it always gives me an error or gives me a blank graph.
0 comentarios
Respuestas (1)
Guillaume
el 16 de Nov. de 2014
The bit in brackets after the @ are the arguments of the anonymous function. The bit after that is what to do with these arguments.
In h_funct, you're not doing anything with your argument. Maybe you ought to pass it to the other functions.
0 comentarios
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!