Modellierung und Simulation - Graphische Darstellung: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Die Seite wurde neu angelegt: „= Aufgabe 2.2 - Plotten von symbolischen Funktionen = # Recherchieren Sie, welche Befehle es in MATLAB<sup>®</sup> zur Darstellung von Funktionsgraphen gibt. # Zeichnen Sie folgenden symbolischen Funktionsgraphen <br> <math>y = \frac{x^2-4}{x^2+1}</math><br><math>y = \frac{x^3-5x^2+8x-4}{x^3-6x^2+12x-8}</math><br><math>y = 2\cdot \sin(3x-\frac{\pi}{6})</math> # Recherchieren Sie, welche Befehle es in MATLAB zur Darstellung von Funktionsgraphen von Funkti…“ |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
{| class="wikitable" | |||
|- | |||
| '''Autor:''' || [[Benutzer:Ulrich_Schneider| Prof. Dr.-Ing. Schneider]] | |||
|} | |||
= Aufgabe 2.1 - 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. | |||
# 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" | |||
| <strong>Musterlösung 1 </strong> | |||
|- | |||
| <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> | |||
|- | |||
| <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> | |||
|} | |||
{| role="presentation" class="wikitable mw-collapsible mw-collapsed" | |||
| <strong>Musterlösung 5 </strong> | |||
|- | |||
| <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); | |||
%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> | |||
|} | |||
= Aufgabe 2.2 - Plotten von symbolischen Funktionen = | = Aufgabe 2.2 - Plotten von symbolischen Funktionen = | ||
# Recherchieren Sie, welche Befehle es in MATLAB<sup>®</sup> zur Darstellung von Funktionsgraphen gibt. | # Recherchieren Sie, welche Befehle es in MATLAB<sup>®</sup> zur Darstellung von Funktionsgraphen gibt. | ||
Version vom 17. April 2026, 09:00 Uhr
| Autor: | Prof. Dr.-Ing. Schneider |
Aufgabe 2.1 - 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;
|
Aufgabe 2.2 - Plotten von symbolischen Funktionen
- Recherchieren Sie, welche Befehle es in MATLAB® zur Darstellung von Funktionsgraphen gibt.
- Zeichnen Sie folgenden symbolischen Funktionsgraphen
- Recherchieren Sie, welche Befehle es in MATLAB zur Darstellung von Funktionsgraphen von Funktionen zweier Veränderlicher gibt.
- Zeichnen Sie folgenden symbolischen Funktionsgraphen
Nützliche Befehle: figure, subplot, syms, fplot, xlabel
| Musterlösung 2.2.2 |
close all
syms x y1 y2 y3
y1 = (x.^2 - 4)./(x.^2 +1);
y2 = (x.^3 - 5.*x.^2 + 8.*x - 4)./(x.^3 - 6.*x.^2 + 12.*x -8);
y3 = 2.*sin(3.*x - (pi/6));
figure(1);
subplot(1,3,1);
fplot(y1);
xlabel('$y = \frac{x^2-4}{x^2+1}$','Interpreter','latex')
subplot(1,3,2);
fplot(y2);
xlabel('$y = \frac{x^3-5x^2+8x-4}{x^3-6x^2+12x-8}$','Interpreter','latex')
subplot(1,3,3);
fplot(y3);
xlabel('$y = 2\cdot \sin(3x-\frac{\pi}{6})$','Interpreter','latex')
|
| Musterlösung 2.2.4 |
syms x y z1 z2
z1 = (x.^2 - y.^2)./(x.^2 + y.^2);
z2 = -4.*x.^3.*y.^2 + 3.*x.*y.^4 - 3.*x + 2.*y + 5;
figure(2)
subplot(1,2,1);
%fsurf(z1);
%fmesh(z1);
%fimplicit3(z1);
fcontour(z1);
subplot(1,2,2);
fsurf(z2);
%fmesh(z2);
%fimplicit3(z2);
%fcontour(z2);
|
→ zurück zum Hauptartikel: BSE Modellierung und Simulation - SoSe26