echo on % % Durch Aktivieren des Kommandofensters und % Druecken einer beliebigen Taste (nach 'pause') fordern Sie % das Programm zum Weiterlaufen auf. % Mit Ctrl C wird das Programm vorzeitig beendet. % % 2d plots % % Funktionsgraphen x=0:0.1:2*pi; plot(x,cos(x)) pause plot(x,cos(x),'-',x,sin(x),'-.') axis([-0.1 2*pi+0.1 -1.1 1.1]) legend('Cosinus','Sinus') xlabel('x') ylabel('f(x)') pause figure % oeffnet neues plotfenster plot(x,cos(x)) pause hold on % naechster plot wird dazugezeichnet plot(x,sin(x),'.-') title('Zwei Funktionen') grid on pause hold off % alter plot wird von naechstem plot ueberschrieben area(x,sin(x)) pause % subplots close(1) % schliesst erstes Fugurfenster clf % clear figure: reinigt aktuelles plotfenster subplot(2,1,1) plot(x,sin(x),'.-') subplot(2,1,2) plot(x,cos(x),'d') pause % Punktwolken clf x=[1 2 3 4]; y=[1 2.5 -1 0.5]; plot(x,y,'o') axis([0 5 -2 3]) pause clf % parametrische Kurven in der Ebene figure(1) % zeichnet naechsten Plot in Plotfenster 1 t=linspace(0,2*pi,100); plot(sin(t),cos(t)) pause axis square pause % Kurven in der Ebene in Polardarstellung t=linspace(0,2*pi,100); r=0.5*ones(1,length(t)); % Vektor der Radien polar(t,r,'.') pause % ACHTUNG! % polar(t,0.5,'.') % gibt Fehlermeldung: % ??? Error using ==> polar % THETA and RHO must be the same size. % % % Polygone t=(1/8:2/8:15/8)'*pi; % Spaltenvektor [pi/8;3pi/8;...;15pi/8] x=sin(t); y=cos(t); figure fill(x,y,'r') % rotes Polygon mit Eckkoord.(x(i), y(i)) axis square pause % 3d plots % % Funktionsgraphen close all % schliesse alle bisherigen Plotfenster x=-7.5:0.5:7.5;y=x; [X,Y]=meshgrid(x,y); Z=3*X+sin(Y); mesh(X,Y,Z) figure surf(X,Y,Z) pause close all % Parametrisierte 2-Flaechen im Raum s=linspace(-10,10,200);t=s; [S,T]=meshgrid(s,t); mesh(S,S.^2,S+T) pause % Niveaulinien von Funktionsgraphen im Raum x=-3:0.05:3;y=x; [X,Y]=meshgrid(x,y); Z=X.^2+Y.^2; contour(X,Y,Z) pause pcolor(X,Y,Z) pause contour(X,Y,Z,20,'k') % 'k' erzeugt schwarze Niveaulinien pause mesh(X,Y,Z) hold on contour(X,Y,Z,20,'k') hold off pause % Niveaulinien implizit definierter Funktionen in der Ebene x=-2:0.05:2;y=x; [X,Y]=meshgrid(x,y); Z=X.^2+Y.^2; contour(X,Y,Z,[1 1]) % Niveaulinie zu Z=1 pause axis square pause % Parametrisierte Kurven im Raum t=linspace(0,6*pi,200); plot3(sin(t),cos(t),t) pause close all % schliesst alle Figurenfenster % ENDE echo off