Setting graph figure size

The properties that can be set for a figure is referenced here. You could then use: figure_number = 1; x = 0; % Screen position y = 0; % Screen position width = 600; % Width of figure height = 400; % Height of figure (by default in pixels) figure(figure_number, ‘Position’, [x y width height]);

How to draw an arrow in Matlab?

You could abuse quiver, this way you don’t have to deal with unhandy normalized figure units by use of annotation drawArrow = @(x,y) quiver( x(1),y(1),x(2)-x(1),y(2)-y(1),0 ) x1 = [10 30]; y1 = [10 30]; drawArrow(x1,y1); hold on x2 = [25 15]; y2 = [15 25]; drawArrow(x2,y2) Important is the 5th argument of quiver: 0 which … Read more

Automatically plot different colored lines

You could use a colormap such as HSV to generate a set of colors. For example: cc=hsv(12); figure; hold on; for i=1:12 plot([0 1],[0 i],’color’,cc(i,:)); end MATLAB has 13 different named colormaps (‘doc colormap’ lists them all). Another option for plotting lines in different colors is to use the LineStyleOrder property; see Defining the Color … Read more

How should I update the data of a plot in Matlab?

Short answer : always use Set(‘Xdata’,…’). Example code: function PlotUpdate() x = 0:.1:8; y = sin(x); h = plot(x,y); y = sin(x.^3); set(h,’XData’,x,’YData’,y); end Long answer: There are three relevant measures by which one should choose the best method. Code clarity – How easy it is for someone to read your code? Runtime – How … Read more

tech