From: Johannes Drever on
Hi, the correct usage of plotyy is illustrated by the following example. The key is to use anonymous functions:

figure(1)
clf

x = -pi:0.1:pi;

y1 = sin(x);
y2 = cos(repmat(x, 10, 1)) .* 3 + randn(10, length(x));

[ax, h1, h2] = plotyy(x, y1, x, mean(y2), 'plot', @(x, y) errorbar(x, y, std(y2)));

cheers,
Johannes