Matlab plot ksdensity without first storing its arguments -
in matlab, if want plot density of variable v have do
[x, y] = ksdensity(v); plot (y, x); if plot(ksdensity(v)), plots x , not x vs y.
is there easier alternative give ksdensity() argument plot() , same job plot(y, x)?
you can refactor function takes in v , plots y vs x:
function h = plot_ksdensity(v, varargin) [x, y] = ksdensity(v); h = plot (y, x, varargin{:}); end using varargin means still have access plot options colours. hold on still work because calls regular plot function.
Comments
Post a Comment