cd('C:\users\krsek\rob06l\Source')
h = hilbert(5)
clear functions
path
addpath('C:\users')
rmpath('C:\users')
which
t = 0:pi/10:2*pi;
y = sin(t);
plot(y)
plot(t,y)
y2 = sin(t-.25);
y3 = sin(t-.5);
f = figure;
plot(t,y,'r.',t,y2,'',t,y3,'--o')
figure(2);
[X,Y] = meshgrid(-8:.5:8,-5:.2:5);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
mesh(X,Y,Z)
surf(Z)
plot3(X,Y,Z)
[x,y,z] = peaks;
contour(x,y,z,20,'k')
hold on
pcolor(x,y,z)
hold off;
colormap(gray)
colormap(hot)
axis off, axis on
axis equal
axis([xmin xmax ymin ymax])
axis square
axis auto
figure(1), clf
t = 0:pi/10:2*pi; y = sin(t);
y2 = sin(t-.25); y3 = sin(t-.5);
plot(t,y,'r.',t,y2,'',t,y3,'--o');
grid on
box off
axis([0 2*pi -1 1])
title('Tri krivky')
xlabel('0 \leq {\itt} \leq 2\pi')
ylabel('sin(t-x_0)')
ht = text(2,-1/3,'\it{inflexni bod}');
line([2.5,pi],[-0.3,0]);
legend('jedna','dva','tri');
get(ht)
set(ht, 'FontSize', 12)
set(ht, 'FontSize', 16, 'FontWeight','bold')
get(gcf)
get(gca)
set(gca, 'xtick', 0:.5:6.5)
helpdesk
print -depsc graf
print -dtiff graf
s = 'ahoj';
disp(s);
o(:,:,1) = [1 2; 3 4];
o(:,:,2) = [5 6; 7 8]
pes.druh = 'kokrspanel';
pes.jmeno = 'Abraxas';
pes
pes.druh
pes(2).druh = 'maxipes';
pes(2).jmeno = 'Fik';
zvire = {};
zvire{1} = pes(1);
zvire{2} = pes(2);
zvire{3} = 'zirafa'
zvire{2}
p1 = 'radka';
p2 = 'dlouha radka';
p = [p1; p2];
p = {p1; p2};
P1 = p{1,1}
P2 = p(1,1)
whos P1 P2
s = 1 -1/2 + 1/3 -1/4 + 1/5 - 1/6 + 1/7 ...
- 1/8 + 1/9 - 1/10 + 1/11 - 1/12;
save matfile y y2 y3
save matfile
save asciifile.txt y -ASCII
load matfile
w = load('matfile.mat')
w = load('asciifile.txt','-ASCII')
A = magic(4)
det(A)
inv(A)
rank(A)
eig(A)
[V,D] = eig(A)
[U,S,V] = svd(A)
y1 = 2
y2 = 6;
x1 = 3; x2 = 8;
a = [x1, y1]
b = [x2, y2];
figure(1);
plot([a(1); b(1)],[a(2); b(2)],'b+');
axis([0 10 0 10]);
yi = [a(2); b(2)]
xi = [a(1); b(1)]
x = [xi ones(size(xi,1),1)]
q = inv(x) * yi
q = x \ yi
figure(1);
xo = [-1:10]';
xo = [xo ones(size(xo,1),1)];
yo = xo*q
hold on
plot(xo(:,1),yo,'g-')
hold off
grid on
x = [xi yi ones(size(xi,1),1)]
[u, s, v] = svd(x)
a = v(:,end)
n = 20;
h = hilbert(n);
ai = ones(n,1);
b = h*ai;
x = [h, -b];
[u s v] = svd(x);
a = v(:,end);
a = a./a(end);
ao = a(1:end-1);
sum(abs(ao-ai))
sum(abs(h*ao - b))