42
KIT – Universität des Landes Baden-Württemberg und nationales Forschungszentrum in der Helmholtz-Gemeinschaft www.iam.kit.edu/wet Vorlesung Batteriemodellierung mit MATLAB Grundlagen MATLAB

BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Embed Size (px)

Citation preview

Page 1: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

KIT – Universität des Landes Baden-Württemberg undnationales Forschungszentrum in der Helmholtz-Gemeinschaft www.iam.kit.edu/wet

Vorlesung Batteriemodellierung mit MATLAB

Grundlagen MATLAB

Page 2: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 2

www.iam.kit.edu/wet

Batteriemodellierung mit MATLABVorlesung 2 - Inhalte

IAM-WET

• MATLAB Installation, Lizenz etc.

• Bedarf - Rechner für Übungen

• Erste Schritte

• MATLAB Oberfläche

• Variablen – Zahlen, Vektoren, Matrizen

• mathematische Operatoren

• weitere MATLAB-Kommandos

Page 3: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 3

www.iam.kit.edu/wet

Download und Installation von MatlabMatlab herunterladen

https://www.scc.kit.edu/downloads/sca/Matlab-Aktivierung-Studierende-v1.1.pdf

Studierende des KITs haben die Möglichkeit zur privaten Nutzung Matlab kostenlos aus dem online Software-Shop herunterzuladen!

Page 4: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 4

www.iam.kit.edu/wethttps://www.scc.kit.edu/downloads/sca/Matlab-Aktivierung-Studierende-v1.1.pdf

Download und Installation von Matlab

Page 5: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 5

www.iam.kit.edu/wethttps://www.scc.kit.edu/downloads/sca/Matlab-Aktivierung-Studierende-v1.1.pdf

Download und Installation von Matlab

Page 6: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 6

www.iam.kit.edu/wethttps://www.scc.kit.edu/downloads/sca/Matlab-Aktivierung-Studierende-v1.1.pdf

Download und Installation von Matlab

Page 7: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 7

www.iam.kit.edu/wethttps://www.scc.kit.edu/downloads/sca/Matlab-Aktivierung-Studierende-v1.1.pdf

Download und Installation von Matlab

Page 8: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 8

www.iam.kit.edu/wet

Erste Schritte in Matlab

Page 9: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 9

www.iam.kit.edu/wet

Erste Schritte in MatlabOberfläche

Command Window

Workspace

Command History

Current Folder

Page 10: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 10

www.iam.kit.edu/wet

Command Window und Workspace

Page 11: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 11

www.iam.kit.edu/wet

Command History

Page 12: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 12

www.iam.kit.edu/wet

Vektoren

Page 13: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 13

www.iam.kit.edu/wet

Vektoren

Page 14: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 14

www.iam.kit.edu/wet

Matrizen

Page 15: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 15

www.iam.kit.edu/wet

Variablen – Skalare, Vektoren, Matrizen

You can name your MATLAB variables anything you'd like as long as they start with a letter and contain only letters, numbers, and underscores (_).

Page 16: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 16

www.iam.kit.edu/wet

Spezielle Matrizen

Page 17: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 17

www.iam.kit.edu/wet

Transponieren

Page 18: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 18

www.iam.kit.edu/wet

Zahlenfolgen

Page 19: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 19

www.iam.kit.edu/wet

Beispiel: Frequenzvektor (fmin ... fmax, n Punkte / Dekade)

Page 20: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 20

www.iam.kit.edu/wet

Elemente aus Vektoren / Matrizen

Page 21: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 21

www.iam.kit.edu/wet

Spezielle Variablen

Page 22: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 22

www.iam.kit.edu/wet

Operatoren

Page 23: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 23

www.iam.kit.edu/wet

Operatoren

IAM-WET

Page 24: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 24

www.iam.kit.edu/wet

Operatoren

IAM-WET

Page 25: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 25

www.iam.kit.edu/wet

Operatoren

The * operator performs matrix multiplication. The .* operator, in contrast, performs elementwise multiplication and allows you to multiply the corresponding elements of two equally sized arrays.

Page 26: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 26

www.iam.kit.edu/wet

Integrierte Funktionen

http://de.mathworks.com/help/matlab/elementary-math.html

Page 27: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 27

www.iam.kit.edu/wet

Selbstdefinierte Funktionen

Page 28: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 28

www.iam.kit.edu/wet

Function Handle

Page 29: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 29

www.iam.kit.edu/wet

MATLAB Klassen

There are many different data types, or classes, that you can work with in the MATLAB® software. You can buildmatrices and arrays of floating-point and integer data, characters and strings, and logical true and false states.Function handles connect your code with any MATLAB function regardless of the current scope. Tables,structures, and cell arrays provide a way to store dissimilar types of data in the same container.

There are 16 fundamental classes in MATLAB. Each of these classes is in the form of a matrix or array. With theexception of function handles, this matrix or array is a minimum of 0-by-0 in size and can grow to an n-dimensional array of any size. A function handle is always scalar (1-by-1).

All of the fundamental MATLAB classes are shown in the diagram below:

Page 30: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 30

www.iam.kit.edu/wet

Weitere MATLAB-Kommandos

Mehr dazu unter matlab_turorials.pdf nachzulesen

Page 31: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 31

www.iam.kit.edu/wet

Daten einlesen und speichern

Page 32: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 32

www.iam.kit.edu/wet

Daten einlesen und speichern

Page 33: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 33

www.iam.kit.edu/wet

Plots

Page 34: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 34

www.iam.kit.edu/wet

Erste Schritte in MatlabM-Files

Page 35: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 35

www.iam.kit.edu/wet

Erste Schritte in MatlabM-Files

neues M-File öffnen

Page 36: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 36

www.iam.kit.edu/wet

Erste Schritte in MatlabM-Files If-else Anweisung

Page 37: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 37

www.iam.kit.edu/wet

Erste Schritte in MatlabSchleifen

Loop Type Description

while loop Repeats a statement or group of statements while a givencondition is true. It tests the condition before executing the loopbody.

for loop Executes a sequence of statements multiple time and abbreviatesthe code that manages the loop variable

nested loop You can use one or more loops inside any another loop

Page 38: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 38

www.iam.kit.edu/wet

Erste Schritte in Matlabwhile Schleife

Page 39: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 39

www.iam.kit.edu/wet

Erste Schritte in Matlabfor- Schleife

Page 40: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 40

www.iam.kit.edu/wet

Erste Schritte in Matlabverschachtelte for-Schleife

Page 41: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 41

www.iam.kit.edu/wet

GUIs

Page 42: BMML V2 Grundlagen MATLAB - iam.kit.edu in matlab... · When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to

Quelle:

Institut für Angewandte Materialien Werkstoffe der Elektrotechnik

BMML V2 Grundlagen MATLAB.pptx, Folie: 42

www.iam.kit.edu/wet

Apps

A MATLAB® app is a self-contained MATLAB program with a graphical user interface that automates a task or calculation. All the operations required to complete the task - getting data into the app, performing calculations on the data, and getting results are performed within the app. Apps are included in many MATLAB products. In addition, you can create your own apps. The Apps tab on the MATLAB Toolstrip displays all currently installed apps.

You can create your own MATLAB app and package it into a single file that you can distribute to others. The apps packaging tool automatically finds and includes all the files needed for your app. It also identifies any MATLAB products required to run your app.

When you create an app package, MATLAB creates a single app installation file (.mlappinstall) that enables you and others to easily install your app. In particular, when you package an app, the app packaging tool:• Performs a dependency analysis to help you find and add the files your app requires• Reminds you to add shared resources and helper files• Stores information you provide about your app with the app package, including a description, a list of

additional MATLAB products required by your app, and a list of supported platforms• Automates app updates (versioning)

In addition when others install your app:• It is a one-click installation.• Users do not need to manage the MATLAB search path or other installation details.• Your app appears alongside MATLAB toolbox apps in the apps gallery.