Tutorial by Examples

The easiest option to draw a circle, is - obviously - the rectangle function. %// radius r = 2; %// center c = [3 3]; pos = [c-r 2*r 2*r]; rectangle('Position',pos,'Curvature',[1 1]) axis equal but the curvature of the rectangle has to be set to 1! The position vector defines the rect...
Firstly, one can use quiver, where one doesn'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) ...
To plot an ellipse you can use its equation. An ellipse has a major and a minor axis. Also we want to be able to plot the ellipse on different center points. Therefore we write a function whose inputs and outputs are: Inputs: r1,r2: major and minor axis respectively C: center of the ellip...
Create vectors to hold the x- and y-locations of vertices, feed these into patch. Single Polygon X=rand(1,4); Y=rand(1,4); h=patch(X,Y,'red'); Multiple Polygons Each polygon's vertices occupy one column of each of X, Y. X=rand(4,3); Y=rand(4,3); for i=2:3 X(:,i)=X(:,i)+(i-1); % create ...
A (m x n) matrix can be representes by a surface by using surf; The color of the surface is automatically set as function of the values in the (m x n) matrix. If the colormap is not specified, the default one is applied. A colorbar can be added to display the current colormap and indicate the map...
There are three main ways to do sequential plot or animations: plot(x,y), set(h , 'XData' , y, 'YData' , y) and animatedline. If you want your animation to be smooth, you need efficient drawing, and the three methods are not equivalent. % Plot a sin with increasing phase shift in 500 steps x = lin...

Page 1 of 1