%-- 13.10.10 1557 --% cassini(4) cassini(3,1,2,3,4,5) v=[3 -2 3 5 1 -4 0 3] v=[3; -2; 3; 5; 1; -4; 0; 3] v=[3 -2 3 5 1 -4 0 3]' v(0) v(1) v(12) v(5) v(end) u=15 v = linspace(2,5); v = linspace(2,5,10); v = linspace(2,5,10) length(v) size(v) a=3; isscalar(a) isvector(a) v = linspace(2,5,10); disp(v) disp(sprintf('%d, ',v)) sin(v) max(v) z=[2,-4,7] -z y=[2-2i,-4i,3,7+i] y.' y' [1,1,6,-2]+[3,-2,5,0] [1,1,6,-2]+[3,-2,5,0,2] [1,-3,5][2,1,0] [1,-3,5][2;1;0] [1;2;3;4][110] [2,4,5,-1].[1,-1,1,6] [3,5,-2,10].^2 [1 -2 3 14] + 5 10 - [1 -2 3 14] [1 -2 3 14] 2 % [1 -2 3 14] . 2 [1 -2 3 14] . 10 % [1 -2 3 14] 10 [1 -2 3 14] .^ 5 [3,2,-5,10]<[2,3,2,3] [3,2,-5,10]~=[2,0,2,3] [2 1 5 4 0]==[0:5] [2 1 5 4 0]==[0:4] ~[3,2,0,-5,10,0,1] [3,2,-5,10]&[2,0,2,3] [1,2,0,4,-3,-10]|0 u = [2 1 4 -3]; v = [5 -7 2 1]'; uv u = [2 1 4 -3]; v = [5; -7; 2; 1]; uv u = [2 1 4 -3]; v = [5 -7 2 1]; uv' u = [2 1 4 -3]; v = [5 -7 2 1]; dot(u,v) u = [2 1 4]; v = [5 -7 2]; cross(u,v) s1 = 'nejaky text'; nazev = 'Programovani v MATLABu' jmena = ['Ilona'; 'Jana '; 'Ludva'; 'Eva '; 'Pepa ']; str2 = ['Jana'; 'Jarmila'] % chyba! jmena jmena = ['Ilona'; 'Jana '; 'Ludva'; 'Eva '; 'Pepa '] jmena2 = char('Ilona','Jana ','Ludva','Eva','Pepa'); jmena2(2,1) jmena3 = {'Ilona'; 'Jana '; 'Ludva'; 'Eva'; 'Pepa'}; jmena2(2,1) disp(jmena3) s1 = 'Ahoj'; s2 = 'lidi'; pozdrav = [s1 ' ' s2 '!'] % Ahoj lidi! s1 = 'Ahoj'; s2 = 'lidi'; pozdrav = strcat(s1, ' ', s2, '!') % Ahoj lidi! pozdrav = strcat(s1,' ', s2, '!') % Ahoj lidi! clear s1 = 'Ahoj'; s2 = 'lidi'; pozdrav = sprintf('%s %s!', s1, s2) % Ahoj lidi! pozdrav = sprintf('%s%s!', s1, s2) % Ahoj lidi! s1 = 'Ahoj'; s2 = 'lidi'; pozdravy = char(s1, s2, 'nazdárek') % matice se 3 řádky ascii = char(reshape(32127, 32, 3)') % ASCII tabulka ve 3 řádcích str = 'Jana'; str2 = 'Jarmila'; str3 = char([74 97 110 97]); % Jana strcmp(str,str3) strcmp(str2,str3) textik='Mila maminko, mam se dobre!' findstr(textik,'mam') % 6 15 findstr(textik,'b') findstr(textik,'M') % 1 %s = strrep(kde,co,čím) ... case-sensitive nahrazování nakup='3 jogurty, 3 rohliky, 1 mleko' strrep(nakup,'3','4') clear clc figure figure(4) gcf close figure(10) close(10) x=-1:0.01:1; plot(x,2*x.^3-.5*x.^2-x+1,'k') plot(x,2*x.^3-.5*x.^2-x+1,'ko:') plot(x,2*x.^3-.5*x.^2-x+1,['k','x','']) x = 0:0.1:6; y1 = sin(x); y2 = exp(x); plotyy(x,y1,x,y2) x = 0:0.1:6; % nezapomínejme na středník - dat je hodně! y = 10.^x; % umocňování člen po členu operátorem s tečkou ( .^ ) semilogy(x,y) t = 0:.01:2*pi; polar(t, sin(2t).cos(2t), '--r') % čárkovaná červená čára clc x=-pi:pi/25:pi; % nezavisle promenna >> y1=sin(x); y2=cos(x); y3=sin(x).^2;% 3 funkce >> plot(x,y1,'r',x,y2,'b',x,y3,'k') % tri v jednom (cerveny, modry a cerny graf) >> plot(x,y1,'r',x,y2,x,y3,'k') % totez - modra barva se nemusi zadavat >> xlabel('x') % popis osy x >> title('Grafy 3 funkci') % nazev grafu >> legend('sin(x)', 'cos(x)', 'sin^2(x)') % pridani legendy ke grafu grid on grid off xlim([-5 2.3]) ylim([-15 2.3]) axis([-5 2.3 0.5 12.5]) % 1. zpusob axis equal axis square x=-pi:pi/25:pi; % nezavisle promenna >> y1=sin(x); y2=cos(x); y3=sin(x).^2;% 3 funkce >> plot(x,y1,'r') % prvni graf (cerveny) >> hold on % prikreslime neco dalsiho >> plot(x,y2) % prvni graf (modry - netreba udavat barvu) >> plot(x,y3,'k') % treti graf (cerny) >> xlabel('x') % popis osy x >> title('Grafy 3 funkci') % nazev grafu >> legend('sin(x)', 'cos(x)', 'sin^2(x)') % pridani legendy ke grafu >> hold off % uz nic prikreslovat nebudeme x=-2*pi:pi/50:2*pi; >> subplot(1,2,1); plot(x,2*x.*cos(x),'k'), title('2x cos x'), axis equal >> subplot(2,2,2); plot(x,3*cos(x).^2,'k'), title('3 cos^2x'), axis equal >> subplot(2,2,4); plot(x,3*abs(cos(x)),'k'), title('3 |cos x|'), axis equal x=-1:0.01:1; >> subplot(2,2,1); plot(x,2*x.^2+1,'k'), title('2x^2+1') >> subplot(2,4,3); plot(x,x.^3,'k'), title('x^3') >> subplot(2,4,4); plot(x,x.^5,'k'), title('x^5') >> subplot(2,1,2); plot(x,x.^2-0.25,'k'), title('x^2-0.25') figure(10) gcf get(10) get(10,'color') figure % dalsi nove okno cara = plot([0.10.510],log([0.10.510])); % vykresleni grafu, s odebranim handle get(cara) % vypis vlastnosti cary grafu set(cara,'Marker','o','MarkerSize',10) % znacka = kolecko, velikost znacky 10 set(cara,'MarkerEdgeColor',[1 0 0]) % cervena hrana znacky set(cara,'MarkerFaceColor',[1 1 0]) % zluta vypln znacky clear clc A = [0:2:18; 2:2:20; 10:-1:1; 20:-2:2; 30:-3:3]; >> imagesc(A) % colormap(jet) %cviceni [v,s]=posloupnost(1,2,10) clc h=prevod10(32) h=prevod10(1234) mod(32,16) fib=fibonacci3(8) [a,b,c,d,e,f,g,h]=fibonacci2 clc o=lezi_na_primce([1,1],[-4,4],[3,-15],[0,85]) clc o=lezi_na_primce([1,1],[-4,4],[3,-15],[0,85]) o=lezi_na_primce([1,1],[-4,4],[3,-1],[0,85]) o=lezi_na_primce([1,1],[-4,4],[3,-.2],[0,85]) clc o=lezi_na_primce([1,1],[-4,4],[3,-.2],[0,85]) o=lezi_na_primce([1,1],[-4,4],[3,-.2],[0,8]) docmax doc max clc close all clc uloha73 uloha76