Final Presentation Winter 2011-2012 Barak Shaashua Barak Straussman Supervisor: Idan Shmuel.
Barak Shenhav Early Evolution Course 11 Feb 2001 MATLAB Visualization, Functions & Debugging.
-
Upload
jason-burns -
Category
Documents
-
view
219 -
download
0
Transcript of Barak Shenhav Early Evolution Course 11 Feb 2001 MATLAB Visualization, Functions & Debugging.
Barak Shenhav
Early Evolution Course
11 Feb 2001
MATLAB Visualization, Functions & Debugging
Visualization
Getting Started
Creating a Plot
x = 0:pi/100:2*pi;
y = sin(x);
plot(x, y)
Multiple Data Sets
y2 = sin(x - .25);
y3 = sin(x - .5);
plot(x, y, x, y2, x, y3)
legend('sin(x)', 'sin(x - .25)', 'sin(x - .5)')
Line Styles, Colors and Markers
plot(x, y, 'r:+')
x1 = 0:pi/100:2*pi;
x2 = 0:pi/10:2*pi;
plot(x1, sin(x1), 'r:', x2, sin(x2), 'r+')
Multiple Plots
plot(x, y, 'r')
figure
plot(x, y, 'b')
figure(1)
plot(x, y, 'g')
close all
subplot(2, 2, 1);
plot(x, y, 'r')
subplot(2, 2, 2);
plot(x, y, 'b')
subplot(2, 2, 3);
plot(x, y, 'g')
subplot(2, 2, 4);
plot(x, y, 'y')
Axes Controlplot(x, y, x, y2, x, y3) axis([0 2*pi –1 1])grid on
axis autoaxis offaxis onaxis equalaxis square
Other Plotsplot - Graph 2-D data with linear scales for both axes
plot3 - Graph 3-D data with linear scales for both axes
loglog - Graph with logarithmic scales for both axes
semilogx - Graph with a logarithmic scale for the x-axis and a linear scale for the y-axis
semilogy - Graph with a logarithmic scale for the y-axis and a linear scale for the x-axis
plotyy - Graph with y-tick labels on the left and right side
3-D Plot
t = 0:pi/50:10*pi;
plot3(sin(t), cos(t), t)
grid on
axis square
Labels and Titles
x = -pi:pi/100:pi;
y = sin(x);
plot(x,y)
axis([-pi pi -1 1])
ylabel('sin(x)')
xlabel('-\pi \leq {\itx} \leq \pi')
title('\fontsize{16}Graph of the sine function')
text(1,-1/3,'\bf{Note the odd symmetry.}')
Get Properties
Finding handles:
• gcf - get current figure handle
• gca - get current axes handle
Getting properties :
• get(h) - all properties of the graphics object identified by the handle h.
• get(h, 'PName') - get the value of the property ‘PName' of the graphics object identified by h.
Set PropertiesSetting properties :
• set(h, ’PName', PValue, ...) - sets the named properties to the specified values on the object(s) identified by the handle(s).
For example :
x = -pi:.1:pi;y = sin(x);plot(x, y)set(gca, 'XTick', -pi:pi/2:pi)set(gca, 'XTickLabel', {'-pi','-pi/2','0','pi/2','pi'})
Bar Chartsy = round(rand(5,3)*10);subplot(2 , 2, 1)bar(Y, 'group')title 'Group'subplot(2, 2, 2)bar(Y, 'stack')title 'Stack'subplot(2, 2, 3)barh(Y, 'stack')title 'Stack'subplot(2, 2, 4)bar(Y,1.5)title 'Width = 1.5'
Pie Chart
val = [12 17 21];explode = [0 0 1];h = pie(val, explode);colormap summertextObjs = findobj(h, 'Type', 'text');newStr = {'X'; 'Y'; 'Z'};set(textObjs, {'String'}, newStr)
Histogram
Y = randn(10000,3);
hist(Y)
Contour and Quiver
n = -2.0:.2:2.0;
[X,Y,Z] = peaks(n);
[C, h] = contour(X,Y,Z,10);
Colormap('default');
clabel(C,h)
[U,V] = gradient(Z,.2);
hold on
quiver(X,Y,U,V)
hold off
Mesh
[U, V] = meshgrid(-8:.5:8);
R = sqrt(U.^2 + V.^2) + eps;
H = sin(R)./R;
mesh(H)
Surf
surf(X, Y, Z, 'FaceColor', 'interp', …
'EdgeColor', 'none', … 'FaceLighting', 'phong')
axis tight
view(-50,30)
camlight left
MoviesZ = peaks;surf(Z); axis tightset(gca, 'nextplot', 'replacechildren');% Record the moviefor j = 1:20
surf(sin(2*pi*j/20)*Z, Z) M(j) = getframe;end% Play the movie twenty timesmovie(M,20)
Saving Figures
From menu:
• File Save – MATLAB format
• File Export – Other graphics formats
From command line:
• Saveas(gcf, filename, extension)
The Importance of Being Lognormal
c Lognormal
Normal
Where Did Life Start ?
Life Started Here
Q=N/NG
0 20 40 60 80 1000
20
40
60
80
100
time
time
0.15
0.30
0.45
0.60
0.75
0.90
Compositional Carpet
Functionsfunction r = rank(A,tol)% RANK Matrix rank.% RANK(A) provides an estimate of the number of% linearly independent rows or columns of a% matrix A.% RANK(A,tol) is the number of singular values of % A that are larger than tol.% By default tol = max(size(A)) * norm(A) * eps.
s = svd(A);if nargin==1
tol = max(size(A)) * max(s) * eps;endr = sum(s > tol);
MATLAB Components
MATLAB Editor
Editor Toolbar
Step in/over
Breakpoint
Evaluation
Quit
The function call stack
Strings
s1 = 'Hello world 1'
s2 = ['Hello ' 'world' ' 2']
s3 = ['Hello world ' num2str(3)]
s4 = sprintf('Hello world %d', 4)
s5 = ['Hello' ; 'world' ; 'in' ; 'lines'] % ERROR
s5 = char({'Hello' ; 'world' ; 'in' ; 'lines'}) % OK
Symbolic Math Toolbox-Funtool