Einfache verschiedene Grundplots
Liniendiagramm
![Einfacher Sinus Einfacher Sinus](https://share-your-photo.com/img/c51a5db1fb_album.png)
x = 0:pi/100:2*pi; y = sin(x); plot(x,y)
![Multiple Linien Multiple Linien](https://share-your-photo.com/img/4660075a1d_album.png)
x = linspace(-2*pi,2*pi); y1 = sin(x); y2 = cos(x); plot(x,y1,x,y2)
![Linienvariation Linienvariation](https://share-your-photo.com/img/e5e3ed6c5f_album.png)
x = 0:pi/100:2*pi; y1 = sin(x); y2 = sin(x-0.25); y3 = sin(x-0.5); plot(x,y1,x,y2,'--',x,y3,':')
Säulendiagramm
![Einfaches Säulendiagramm Einfaches Säulendiagramm](https://share-your-photo.com/img/ce9bf4e979_album.png)
y = [10 15 20 30 22]; bar(y)
![Beschrifteter X-Achse Beschrifteter X-Achse](https://share-your-photo.com/img/8903bec3e6_album.png)
x = 1900:10:2000; y = [10 15 20 30 22]; bar(x,y)
![Säulendicke Säulendicke](https://share-your-photo.com/img/0791dab151_album.png)
y = [10 15 20 30 22]; bar(y,0.5)
![Säulengruppierung Säulengruppierung](https://share-your-photo.com/img/066050f422_album.png)
y = [1 2 3; 4 5 6; 7 8 9; 10 11 12]; bar(y)
![Gestapelt Gestapelt](https://share-your-photo.com/img/d00b953a43_album.png)
y = [1 5 9; 2 6 10; 3 7 11; 4 8 12]; bar(y,'stacked')
Balkendiagramm
![Einfaches Balkendiagramm Einfaches Balkendiagramm](https://share-your-photo.com/img/14bb718b68_album.png)
y = [10 15 20 30 22]; barh(y)
![Beschrifteter X-Achse Beschrifteter X-Achse](https://share-your-photo.com/img/f0bc48ad7a_album.png)
x = 1900:10:2000; y = [10 15 20 30 22]; barh(x,y)
![Balkendicke Balkendicke](https://share-your-photo.com/img/bc7f7ac902_album.png)
y = [10 15 20 30 22]; barh(y,0.5)
![Balkengruppierung Balkengruppierung](https://share-your-photo.com/img/153fd0eea2_album.png)
y = [1 2 3; 4 5 6; 7 8 9; 10 11 12]; barh(y)
![Gestapelt Gestapelt](https://share-your-photo.com/img/d3e42a95f5_album.png)
y = [1 5 9; 2 6 10; 3 7 11; 4 8 12]; barh(y,'stacked')
Histogramm
![Einfache aus Zufallszahlen Einfache aus Zufallszahlen](https://share-your-photo.com/img/9959ba92ea_album.png)
x = randn(500,1); histogram(x)
![Balkenanzahl Balkenanzahl](https://share-your-photo.com/img/27a9db0af7_album.png)
x = randn(500,1); nbins = 25; histogram(x,nbins)
Histogramm - 3D
![Einfache aus Zufallszahlen Einfache aus Zufallszahlen](https://share-your-photo.com/img/9ee46dbd3d_album.png)
x = randn(500,1); y = randn(500,1); histogram2(x,y)
![Balkenanzahl (in jeder Dimension) Balkenanzahl (in jeder Dimension)](https://share-your-photo.com/img/8c4721f304_album.png)
x = randn (1000,1); y = randn (1000,1); nbins = 5; histogramm2 (x, y, nbins)
Kuchendiagramm
![Einfaches Einfaches](https://share-your-photo.com/img/80a61189d8_album.png)
X = [1 2 3 4 5]; pie(X)
![Explodiertes Explodiertes](https://share-your-photo.com/img/fcea2a9c83_album.png)
X = [1 2 3 4 5]; explode = [0 1 0 1 0]; // bei 1 ist das Kuchenstück herausgenommen pie(X,explode)
![Küchenstücke Beschriftet Küchenstücke Beschriftet](https://share-your-photo.com/img/735c823a08_album.png)
X = [1 2 3 4 5]; labels = {'PIE 1', 'PIE 2', 'PIE 3', 'PIE 4', 'PIE 5'}; pie(X,labels)
Kuchendiagramm - 3D
![Einfaches Einfaches](https://share-your-photo.com/img/dd934e1d34_album.png)
X = [1 2 3 4 5]; pie3(X)
![Explodiertes Explodiertes](https://share-your-photo.com/img/006bdb2e93_album.png)
X = [1 2 3 4 5]; explode = [0 1 0 1 0]; // bei 1 ist das Kuchenstück herausgenommen pie3(X,explode)
![Küchenstücke Beschriftet Küchenstücke Beschriftet](https://share-your-photo.com/img/f3ff08c1c3_album.png)
X = [1 2 3 4 5]; labels = {'PIE 1', 'PIE 2', 'PIE 3', 'PIE 4', 'PIE 5'}; pie3(X,labels)
Streudiagramm
![Einfache Sinus mit Zufallszahlen Einfache Sinus mit Zufallszahlen](https://share-your-photo.com/img/a3510b88d2_album.png)
x = linspace(0,3*pi,200); y = sin(x) + rand(1,200); scatter(x,y)
![Unterschiedliche Kreisgröße (wird auf X-Achse größer) Unterschiedliche Kreisgröße (wird auf X-Achse größer)](https://share-your-photo.com/img/98899174d1_album.png)
x = linspace(0,3*pi,200); y = sin(x) + rand(1,200); sz = linspace(1,100,200); scatter(x,y,sz)
![Unterschiedliche Kreisfarben Unterschiedliche Kreisfarben](https://share-your-photo.com/img/f546080866_album.png)
x = linspace(0,3*pi,200); y = sin(x) + rand(1,200); c = linspace(1,10,length(x)); scatter(x,y,[],c)
Streudiagramm - 3D
![Einfache Sinus mit Zufallszahlen Einfache Sinus mit Zufallszahlen](https://share-your-photo.com/img/84650a145b_album.png)
[X,Y,Z] = sphere(16); x = [0.5*X(:); 0.75*X(:); X(:)]; y = [0.5*Y(:); 0.75*Y(:); Y(:)]; z = [0.5*Z(:); 0.75*Z(:); Z(:)]; scatter3(x,y,z)
![Unterschiedliche Kreisgröße Unterschiedliche Kreisgröße](https://share-your-photo.com/img/bda074b981_album.png)
[X,Y,Z] = sphere(16); x = [0.5*X(:); 0.75*X(:); X(:)]; y = [0.5*Y(:); 0.75*Y(:); Y(:)]; z = [0.5*Z(:); 0.75*Z(:); Z(:)]; S = repmat([100,50,5],numel(X),1); s = S(:); scatter3(x,y,z,s) view(40,35)
![Unterschiedliche Kreisfarben Unterschiedliche Kreisfarben](https://share-your-photo.com/img/1e15f68289_album.png)
[X,Y,Z] = sphere(16); x = [0.5*X(:); 0.75*X(:); X(:)]; y = [0.5*Y(:); 0.75*Y(:); Y(:)]; z = [0.5*Z(:); 0.75*Z(:); Z(:)]; S = repmat([50,25,10],numel(X),1); C = repmat([1,2,3],numel(X),1); s = S(:); c = C(:); scatter3(x,y,z,s,c) view(40,35)
Oberflächendiagramm
![Einfach Einfach](https://share-your-photo.com/img/9c53276a15_album.png)
[X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); surf(X,Y,Z)
![Mit Farbbar Mit Farbbar](https://share-your-photo.com/img/6f3d74634a_album.png)
[X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); C = X.*Y; surf(X,Y,Z,C) colorbar
Netzdiagramm
![Einfach Einfach](https://share-your-photo.com/img/3529338696_album.png)
[X,Y] = meshgrid(-8:.5:8); R = sqrt(X.^2 + Y.^2) + eps; Z = sin(R)./R; mesh(X,Y,Z)
![Spezifischer Farbe Spezifischer Farbe](https://share-your-photo.com/img/daf15ba7f3_album.png)
[X,Y] = meshgrid(-8:.5:8); R = sqrt(X.^2 + Y.^2) + eps; Z = sin( R)./R; C = gradient(Z); mesh(X,Y,Z,C)
Erweiterte/Spezifische Plots
Die Daten für dieses Beispiel sind Bewegungsdaten von einem Balance Board.
Dabei wurde die X-Achse und Y-Achse aufgezeichnet.
Die 2 Signale sollen in 6 Segmente geteilt werden und der 2te Abschnitt soll Hervorgehoben werden.
Danach soll noch eine Zusammenfassung beider Signale in einem Plot erstellt werden.
![Bewegungsgrafik Bewegungsgrafik](https://share-your-photo.com/img/3a768e9830_album.png)
close all, clear all, clc % komplett Bereinigung (Variablen, Plotfenster usw.) load('x.mat') load('y.mat') % Läd die Daten für X- und Y-Achse figure % erstellt ein neues Fenster mit Standardeigenschaftswerten fre = 1500; seg_sec = 20; % Die Daten haben eine Gesamtzahl von 180000 Datensätzen und es sollen 6 Segmente entstehen, % deshalb ist die Frequenz bei 1500 Hz und jeder Segment abschnitt sind 20 Sekunden. i = 1; subplot(2,2,1) hold on % warten auf alle Daten die in der einen Grafik dargestellt werden sollen %Grafik Nummer 1 test = plot(x,'b') test.Color(4) = 0.3; plot((i)*seg_sec*fre+1:(i+1)*seg_sec*fre,x((i)*seg_sec*fre+1:(i+1)*seg_sec*fre),'r','LineWidth',2) % Formatierung des Plots: xticks ([0 30000 60000 90000 120000 150000 180000]) xticklabels ({'0','20','40','60','80','100','120'}) xlabel ('Messdauer[s]') % Formatierung der X-Achse in die Größen anzeige von 20 Sekunden yticks ([-4 -3 -2 -1 0 1 2]) yticklabels ({'-40','-30','-20','-10','0','10','20'}) ylabel ('ML [mm]') % Formatierung der Y-Achse line([30000,30000],[-4,2],'Color',[0 0 0]) line([60000,60000],[-4,2],'Color',[0 0 0]) line([90000,90000],[-4,2],'Color',[0 0 0]) line([120000,120000],[-4,2],'Color',[0 0 0]) line([150000,150000],[-4,2],'Color',[0 0 0]) % Einzeichnung von Linien zum visuellen Abtrennung der Segmente % Andere Variante zur Erstellung von Grafik 2 subplot(2,2,3),plot((i-1)*seg_sec*fre+1:i*seg_sec*fre,y((i-1)*seg_sec*fre+1:i*seg_sec*fre),'b') hold on subplot(2,2,3),plot((i)*seg_sec*fre+1:(i+1)*seg_sec*fre,y((i)*seg_sec*fre+1:(i+1)*seg_sec*fre),'r') subplot(2,2,3),plot((i+1)*seg_sec*fre+1:(i+2)*seg_sec*fre,y((i+1)*seg_sec*fre+1:(i+2)*seg_sec*fre),'b') subplot(2,2,3),plot((i+2)*seg_sec*fre+1:(i+3)*seg_sec*fre,y((i+2)*seg_sec*fre+1:(i+3)*seg_sec*fre),'b') subplot(2,2,3),plot((i+3)*seg_sec*fre+1:(i+4)*seg_sec*fre,y((i+3)*seg_sec*fre+1:(i+4)*seg_sec*fre),'b') subplot(2,2,3),plot((i+4)*seg_sec*fre+1:(i+5)*seg_sec*fre,y((i+4)*seg_sec*fre+1:(i+5)*seg_sec*fre),'b') % Das b (blue) und r (red) sind die Farben welche jedes Segment bekommt % Beim subplot werden die Positionen für die Grafik mit angefügt an welcher Stelle die Funktion zu sehen ist xticks ([0 30000 60000 90000 120000 150000 180000]) xticklabels ({'0','20','40','60','80','100','120'}) xlabel ('Messdauer[s]') yticks ([0 1 2 3 4 5 6]) yticklabels ({'0','10','20','30','40','50','60'}) ylabel ('AP [mm]') line([30000,30000],[0,6],'Color',[0 0 0]) line([60000,60000],[0,6],'Color',[0 0 0]) line([90000,90000],[0,6],'Color',[0 0 0]) line([120000,120000],[0,6],'Color',[0 0 0]) line([150000,150000],[0,6],'Color',[0 0 0]) % Grafik Nummer 3 subplot(2,2,[2,4]),plot(x((i)*seg_sec*fre+1:(i+1)*seg_sec*fre),y(i*seg_sec*fre+1:(i+1)*seg_sec*fre),'b:') hold on subplot(2,2,[2,4]),plot(x((i+1)*seg_sec*fre+1:(i+2)*seg_sec*fre),y((i+1)*seg_sec*fre+1:(i+2)*seg_sec*fre),'r:','LineWidth',2 ) subplot(2,2,[2,4]),plot(x((i+2)*seg_sec*fre+1:(i+3)*seg_sec*fre),y((i+2)*seg_sec*fre+1:(i+3)*seg_sec*fre),'b:') subplot(2,2,[2,4]),plot(x((i+3)*seg_sec*fre+1:(i+4)*seg_sec*fre),y((i+3)*seg_sec*fre+1:(i+4)*seg_sec*fre),'b:') subplot(2,2,[2,4]),plot(x((i+4)*seg_sec*fre+1:(i+5)*seg_sec*fre),y((i+4)*seg_sec*fre+1:(i+5)*seg_sec*fre),'b:') % Hinter b und r der ":" zeigt welche Form die Linie im Plot hat, Standardmäßig ist es eine durchgezogene Linie % LineWidth,2 legt die Liniendicke des Roten Teilabschnittes fest xticks ([-4 -3 -2 -1 0 1]) xticklabels ({'-40','-30','-20','-10','0','10'}) xlabel ('medio-lateral [mm]') yticks ([0 1 2 3 4 5 6]) yticklabels ({'0','10','20','30','40','50','60'}) ylabel ('antorior-posterior [mm]')