Reputation: 165
I want to call plot
with pre-defined parameters.
For example:
Params = {'MarkerSize',3,'MarkerFaceColor',[1 0 0.3]}
plot(data(:,1), data(:,2),Params)
Obviously this is not working, but you get the idea. The purpose of doing so is to generate a function that can plot data (for code reuse purpose), except small modifications. I would like to put in the Params variable only the name-value pairs which are different from the default, and be able to put variable number of pairs.
For example, one time I only put color:
Params = {'Color',[1 0.2 0.3]}
the other time I put both marker and line width:
Params = {'Marker','o','LineWidth',4}
Upvotes: 2
Views: 31
Reputation: 8401
Expand the cell array of name-value pairs into a comma-separated list:
plot(data(:,1), data(:,2),Params{:});
Upvotes: 2