Modellierung und Simulation - Graphische Darstellung: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
| Zeile 3: | Zeile 3: | ||
| '''Autor:''' || [[Benutzer:Ulrich_Schneider| Prof. Dr.-Ing. Schneider]] | | '''Autor:''' || [[Benutzer:Ulrich_Schneider| Prof. Dr.-Ing. Schneider]] | ||
|} | |} | ||
= Aufgabe 2 | = Aufgabe 2 - Plotten von diskreten Werten = | ||
# | # Erzeugen Sie zunächst ein eindimensionales Feld x von 51 aufsteigenden Zahlen zwischen 0 und 5. | ||
# | # Plotten Sie <code>sin(x)</code> über <code>x</code>. | ||
# | # Plotten Sie in einer Figur die Funktionen <math>x\cdot sin(x)</math> und <math>x\cdot log(x)</math> über <code>x</code>. | ||
# | # Plotten Sie nun die Kurve <code>cos(x)</code> über <code>sin(x)</code> für <math>Winkel \in [0..2\pi]</math> in einem neuen Fenster. | ||
'''Nützliche Befehle:''' [https://de.mathworks.com/help/matlab/ref/figure.html <code>figure</code>], [https://de.mathworks.com/help/matlab/ref/ | # Erzeugen Sie ein zweites Feld y=x und plotten Sie über dem von x und y aufgespannten zweidimensionelen Feld die Funktion <math>z=x\cdot sin(x)</math>. | ||
## Beschriften Sie jeweils die Zeichnungen mit Überschrift und Achsenbeschriftung. | |||
## Ordnen Sie die vier plots aus den Aufgaben 1-4 in einem 2x2 Feld an. | |||
## Probieren Sie für (2) verchiedene Arten von Kurvenplots aus (unterschiedliche Farben, durchgezogene, gestrichelte Linien). | |||
## Probieren Sie für (5) verschiedene Arten von Oberflächengestaltung (<code>surf, surfc, plot3</code>). | |||
## Lassen Sie sich in jedem Plot ein Raster anzeigen (<code>grid on</code>). | |||
## Für (5): Stellen sie ein, dass der Plot vom Benutzer rotiert werden kann per Maus (<code>rotate3d on</code>). | |||
'''Nützliche Befehle:''' [https://de.mathworks.com/help/matlab/ref/xlabel.html <code>xlabel</code>], [https://de.mathworks.com/help/matlab/ref/subplot.html <code>subplot</code>], [https://de.mathworks.com/help/matlab/ref/title.html <code>title</code>], [https://de.mathworks.com/help/matlab/ref/title.html <code>hold on</code>], [https://de.mathworks.com/help/matlab/ref/plot.html <code>plot</code>], [https://de.mathworks.com/help/matlab/ref/figure.html <code>figure</code>], [https://de.mathworks.com/help/matlab/ref/grid.html <code>grid on</code>], [https://de.mathworks.com/help/matlab/ref/mesh.html <code>mesh</code>], [https://de.mathworks.com/help/matlab/ref/meshgrid.html <code>meshgrid</code>], [https://de.mathworks.com/help/matlab/ref/surf.html <code>surf</code>], [https://de.mathworks.com/help/matlab/ref/surfc.html <code>surfc</code>], [https://de.mathworks.com/help/matlab/ref/plot3.html <code>plot3</code>], [https://de.mathworks.com/help/matlab/ref/axis.html <code>axis equal</code>], [https://de.mathworks.com/help/matlab/ref/surfc.html <code>zlabel</code>], [https://de.mathworks.com/help/matlab/ref/rotate3d.html <code>rotate3d on</code>] | |||
{| role="presentation" class="wikitable mw-collapsible mw-collapsed" | {| role="presentation" class="wikitable mw-collapsible mw-collapsed" | ||
| <strong>Musterlösung | | <strong>Musterlösung 1 </strong> | ||
|- | |- | ||
| <source line lang="matlab" style="font-size:medium"> | | <source line lang="matlab" style="font-size:medium">x = (0:0.1:5); | ||
</source> | |||
|} | |||
{| role="presentation" class="wikitable mw-collapsible mw-collapsed" | |||
| <strong>Musterlösung 2 </strong> | |||
|- | |||
| <source line lang="matlab" style="font-size:medium">y = sin(x); | |||
subplot(2,2,1) | |||
plot(x,y,'--') | |||
title('sin(x)') | |||
xlabel('x') | |||
ylabel('y') | |||
grid on; | |||
</source> | |||
|} | |||
{| role="presentation" class="wikitable mw-collapsible mw-collapsed" | |||
| <strong>Musterlösung 3 </strong> | |||
subplot( | |- | ||
| <source line lang="matlab" style="font-size:medium">y1 = x.*sin(x); | |||
y2 = x.*log(x); | |||
subplot(2,2,2) | |||
plot(x, y1, 'r.'); | |||
hold on; | |||
plot(x, y2, 'b-'); | |||
title('x*sin(x) | x*log(x)') | |||
xlabel('x') | |||
ylabel('y') | |||
grid on; | |||
</source> | |||
|} | |||
{| role="presentation" class="wikitable mw-collapsible mw-collapsed" | |||
| <strong>Musterlösung 4 </strong> | |||
|- | |||
| <source line lang="matlab" style="font-size:medium">t = (0:pi/100:2*pi); | |||
x = sin(t); | |||
y = cos(t); | |||
subplot(2,2,3) | |||
plot(x,y,'g.-'); | |||
title('cos(x) ueber sin(x)') | |||
xlabel('x') | |||
ylabel('y') | |||
grid on; | |||
</source> | </source> | ||
|} | |} | ||
{| role="presentation" class="wikitable mw-collapsible mw-collapsed" | {| role="presentation" class="wikitable mw-collapsible mw-collapsed" | ||
| <strong>Musterlösung | | <strong>Musterlösung 5 </strong> | ||
|- | |- | ||
| <source line lang="matlab" style="font-size:medium"> | | <source line lang="matlab" style="font-size:medium">[X,Y] = meshgrid(0:0.1:5,0:0.1:5); | ||
Z = X.*sin(Y); | |||
subplot(2,2,4) | |||
%surf(X,Y,Z); | |||
%surfc(X,Y,Z); | |||
subplot( | %plot3(X,Y,Z); | ||
% | mesh(X,Y,Z); | ||
% | %axis equal | ||
% | title('x*sin(y)') | ||
xlabel('x') | |||
ylabel('y') | |||
zlabel('z') | |||
grid on; | |||
rotate3d on; | |||
</source> | </source> | ||
|} | |} | ||
---- | ---- | ||
→ zurück zum Hauptartikel: [[BSE Modellierung und Simulation - SoSe26]] | → zurück zum Hauptartikel: [[BSE Modellierung und Simulation - SoSe26]] | ||
Aktuelle Version vom 24. April 2026, 09:12 Uhr
| Autor: | Prof. Dr.-Ing. Schneider |
Aufgabe 2 - Plotten von diskreten Werten
- Erzeugen Sie zunächst ein eindimensionales Feld x von 51 aufsteigenden Zahlen zwischen 0 und 5.
- Plotten Sie
sin(x)überx. - Plotten Sie in einer Figur die Funktionen und über
x. - Plotten Sie nun die Kurve
cos(x)übersin(x)für in einem neuen Fenster. - Erzeugen Sie ein zweites Feld y=x und plotten Sie über dem von x und y aufgespannten zweidimensionelen Feld die Funktion .
- Beschriften Sie jeweils die Zeichnungen mit Überschrift und Achsenbeschriftung.
- Ordnen Sie die vier plots aus den Aufgaben 1-4 in einem 2x2 Feld an.
- Probieren Sie für (2) verchiedene Arten von Kurvenplots aus (unterschiedliche Farben, durchgezogene, gestrichelte Linien).
- Probieren Sie für (5) verschiedene Arten von Oberflächengestaltung (
surf, surfc, plot3). - Lassen Sie sich in jedem Plot ein Raster anzeigen (
grid on). - Für (5): Stellen sie ein, dass der Plot vom Benutzer rotiert werden kann per Maus (
rotate3d on).
Nützliche Befehle: xlabel, subplot, title, hold on, plot, figure, grid on, mesh, meshgrid, surf, surfc, plot3, axis equal, zlabel, rotate3d on
| Musterlösung 1 |
x = (0:0.1:5);
|
| Musterlösung 2 |
y = sin(x);
subplot(2,2,1)
plot(x,y,'--')
title('sin(x)')
xlabel('x')
ylabel('y')
grid on;
|
| Musterlösung 3 |
y1 = x.*sin(x);
y2 = x.*log(x);
subplot(2,2,2)
plot(x, y1, 'r.');
hold on;
plot(x, y2, 'b-');
title('x*sin(x) | x*log(x)')
xlabel('x')
ylabel('y')
grid on;
|
| Musterlösung 4 |
t = (0:pi/100:2*pi);
x = sin(t);
y = cos(t);
subplot(2,2,3)
plot(x,y,'g.-');
title('cos(x) ueber sin(x)')
xlabel('x')
ylabel('y')
grid on;
|
| Musterlösung 5 |
[X,Y] = meshgrid(0:0.1:5,0:0.1:5);
Z = X.*sin(Y);
subplot(2,2,4)
%surf(X,Y,Z);
%surfc(X,Y,Z);
%plot3(X,Y,Z);
mesh(X,Y,Z);
%axis equal
title('x*sin(y)')
xlabel('x')
ylabel('y')
zlabel('z')
grid on;
rotate3d on;
|
→ zurück zum Hauptartikel: BSE Modellierung und Simulation - SoSe26