I have a several datasets which are Nx2 size. Say, it is called dat1. I want to make a wrapper function myplot()
to plot it using plot()
function without doing plot(dat1(:,1), dat1(:,2))
every time.
It is not a problem, but I want to be able to use all the other properties like 'LineWidth'
, marker etc. the same way as plot()
.
How do I make a wrapper myPlot()
that can interpret the variable arguments similar to plot()
? It should look like this:
myPlot(dat1, 'rx')
should translate to plot(dat1(:,1), data1(:,2),'rx')
myPlot(data1, 'Linewidth',2)
should translate to plot(dat1(:,1), data1(:,2),'Linewidth',2)
Edit: Thanks. Found an answer elsewhere
function h = myPlot(varargin)
dat = varargin{1};
h = plot(dat(:,1), dat(:,2), varargin{2:end});