155GIT1 / 7. cvičení: Porovnání verzí
Řádek 76: | Řádek 76: | ||
<source lang=octave> | <source lang=octave> | ||
x = [0:pi/100:pi]; | x = [0:pi/100:pi]; | ||
figure | |||
plot(x, sin(x)) | plot(x, sin(x)) | ||
title('Funkce sinus') | title('Funkce sinus') |
Verze z 31. 3. 2015, 14:16
Grafy funkcí, uživatelské funkce
Náplň cvičení
- grafické okno
figure
- grafy funkcí
plot(), subplot(), axis()
Ukázky
Grafické okno
figure
Grafy funkcí
plot()
• argumenty
x = [0:pi/50:2*pi];
y = sin(x);
plot(x, y)
%
% nové okno
h = figure
plot(x, y 'r+')
%
% více grafů najednou
z = cos(x);
plot(x, y, 'r+', x, z, 'b*')

plot(x, y, 'r+', x, z, 'b*')
subplot()
x = 1:100;
figure
% první
subplot(2, 2, 1)
plot(x, x)
% druhý
subplot(2, 2, 2)
plot(x, sqrt(x))
% třetí
subplot(2, 2, 3)
plot(x, log(x))
% čtvrtý
subplot(2, 2, 4)
plot(x, x.^2)

subplot()
axis()
- omezení oblasti grafu
x = 0:0.1:5;
y = exp(x);
% celý graf
subplot(2, 1, 1)
plot(x, y)
% výsek x <1, 2>; y <0, 10>
subplot(2, 1, 2)
plot(x, y)
axis([1,2,0,10])

axis()
- popisky
x = [0:pi/100:pi];
figure
plot(x, sin(x))
title('Funkce sinus')
xlabel('hodnota v rad')
ylabel('sin(x)')
legend('prubeh funkce sinus')
