Matlab: Plot multiple anonymous functions using fplot
问题 I am trying to create two anonymous functions and plot them using a single fplot statement. The following code works to plot a single function: f = @(x) sin(x) fplot(f, [-3, 3]) However, when I include the following, it doesn't work: g = @(x) cos(x) fplot([f, g], [-3, 3]) Does anyone know what is the issue here? 回答1: If you really must do this: >> f = @sin; >> g = @cos; >> hold on >> cellfun(@(func) fplot(func, [-3, 3]), {f, g}) This applies the function handle @(func) fplot(func, [-3, 3]) to