Computational Photonics What Is MATLAB?

2y ago
14 Views
4 Downloads
941.14 KB
14 Pages
Last View : 29d ago
Last Download : 3m ago
Upload by : Kaleb Stephen
Transcription

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschComputational PhotonicsSeminar 01, 13 April 2018What is MATLAB? Tool for technical computing Integrated development environment for computation,visualization and programming At the same time higher level programming language and aninteractive tool for numerical work Uses an interpreter just-in-time compilation, many nativelibraries – High-Performance Computing?1

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschComparing MATLAB and Csimple example of a matrix multiplication 1 2 3 9 8 7 30 24 18 A 4 5 6 , B 6 5 4 , C AB 84 69 54 7 8 9 3 2 1 138 114 90

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschMATLAB A [1 2 3; 4 5 6; 7 8 9]A 123456789 B [9 8 7; 6 5 4; 3 2 1]B 987654321 C A*BC 30241884695413811490

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschCEDITOR#include "stdio.h"#includeint main(int "stdio.h"argc, char* argv[]){intmain(int argc, char* argv[])doubleA[3][3] {{1,2,3},{4,5,6},{7,8,9}};double A[3][3] {{1,2,3},{4,5,6},{7,8,9}};{ doubleB[3][3] {{9,8,7},{6,5,4},{3,2,1}};double B[3][3] [3];inti,j,k;(i 0;i 3;{inti,j,k;forfor(i 0;i 3;i i 1)i i 1){for (j 0; j 3; j j 1) {for(j 0; j 3; j j 1) {C[i][j] 0.0;C[i][j] 0.0;for (k 0; k 3; k k 1) {forC[i][j] C[i][j] A[i][k]*B[k][j];(k 0; k 3; k k 1) {}C[i][j] C[i][j] A[i][k]*B[k][j];}printf("C \n");}}forprintf("C \n");(i 0; i 3; i i 1) {}for (i 0;(j 0;j 3;j j 1){i 3;i i 1){} forfor(j 0; j 3; j j 1){printf("%lf",C[i][j]);} } printf("%lf ",C[i][j]);printf("\n");printf("\n");return0;}} }return 0;}

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschCPROMPT cc –o matmul matmul.c ./matmulC 000000 18.00000054.00000090.000000

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschTypical applications of MATLAB Mathematical and numerical workDevelopment of mathematical algorithmsSimulationData acquisition, -analysis, -visualizationDevelopment and implementation of (stand-alone)applications with graphical user interfaces In industry and academia for research and teaching purpose

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschA brief historyThe name MATLAB stands for matrix laboratory.Formerly: Only interface to allow a simplified access on all the tools that havebeen implemented within the projects LINPACK and EISPACK, theirpurpose was matrix operationsToday: includes modern matrix program libraries LAPACK and BLAS TOOLBOXES: extensive collection of MATLAB-functions(M-Files) for special problems and purposes, e.g. signal processing,neural networks, Fuzzy-logic, Wavelets, partial differentialequations, image processing, statistics, symbolic operations

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschThe MATLAB system1. Integrated Development EnvironmentEnvironment for the efficient use of the entire functionality as provided byMATLAB (Command-Window, Editor, Debugger, Help-Browser, .)2. Library of mathematical functionsAll kinds of predefined mathematical functions (sum, sine, cosine, ., matrixinversion, matrix-eigenvalues, Fourier-transformation)3. Language MATLABAllows to call all the mathematical functions, provides a sufficiently large set ofdata structures and primitives for controlling the flow of programs (conditions,loops,.)

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschThe MATLAB system4. Graphicstools for the visualization of vectors and matrices, 2D, 3D, animation,image processing, graphical user interfaces5. Application Programming Interface (API)provides an interface to other programming languages like C undFortran (dynamic linking, computational engine)

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschMATLAB help and primers The MATLAB help (pressing F1 for any unknown function or typing doc orhelp ) is extremely helpful and comprehensive (also online atmathworks.com) The systems consists of thousands of functions in dozens of toolboxes. Forabsolute beginners, reading a primer might be helpful. A google search for“MATLAB primer” or a visit in the library should help.10

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschMATLAB open source alternatives GNU Octave:– Core language mostly compatible to Matlab– Less comfortable IDE– No compatible versions of most Matlab toolboxes (but alternativepackages on Octave Forge) Scilab: Similar to Matlab but not compatible Scientific Python Stack (Python, NumPy, SciPy, Matplotlib, ):– Completely different programming language but comparable functionality– Very large community– Specialized packages for almost any scientific domain– Common distributions: Anaconda Python(x,y) WinPython Enthought Canopy11

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschProgramming tasksNow, you are given a refreshment crash-course inMATLAB in the seminar.12

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschProgramming task 1Plot the sinc-function which is defined as sin(𝑥)/𝑥 within theinterval of [ 3𝜋, 3𝜋] using 301 points. Try to avoid thesingularity which occurs at 𝑥 0 in an appropriate manner!Necessary functions:colon operator:division element by element:v 0sine:function for plotting a line graph::./sinplot

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas PertschProgramming task 2Write down and test a program to compute the sum of all theelements of a matrix.Header of the program:function sm supersum(A)% Sum over all elememnts of a matrix% Command sm supersum (A)% A: arbitrary 2D-matrixCommands you will need: sum, (size)Test with: A magic(9);Compute the sum of all the elements of a magic square.

Computational Photonics, Summer Term 2018, Abbe School of Photonics, FSU Jena, Prof. Thomas Pertsch 1 Computational Photonics Tool for technical computing Integrated development environment for computation, visualization and programming At the same time higher level progra

Related Documents:

Photonics technologies for system-level integration System-level: Scalable chip-to-fiber connectivity Chip-level: CMOS silicon photonics Active photonics devices Si photonics provides all required buliding blocks (except lasers) on chip-level: - Modulators - Drivers - Detectors - Amplifiers - WDM filters CMOS electronics 2 1

MATLAB tutorial . School of Engineering . Brown University . To prepare for HW1, do sections 1-11.6 – you can do the rest later as needed . 1. What is MATLAB 2. Starting MATLAB 3. Basic MATLAB windows 4. Using the MATLAB command window 5. MATLAB help 6. MATLAB ‘Live Scripts’ (for algebra, plotting, calculus, and solving differential .

19 MATLAB Excel Add-in Hadoop MATLAB Compiler Standalone Application MATLAB deployment targets MATLAB Compiler enables sharing MATLAB programs without integration programming MATLAB Compiler SDK provides implementation and platform flexibility for software developers MATLAB Production Server provides the most efficient development path for secure and scalable web and enterprise applications

MATLAB tutorial . School of Engineering . Brown University . To prepare for HW1, do sections 1-11.6 – you can do the rest later as needed . 1. What is MATLAB 2. Starting MATLAB 3. Basic MATLAB windows 4. Using the MATLAB command window 5. MATLAB help 6. MATLAB ‘Live Scripts’ (for

3. MATLAB script files 4. MATLAB arrays 5. MATLAB two‐dimensional and three‐dimensional plots 6. MATLAB used‐defined functions I 7. MATLAB relational operators, conditional statements, and selection structures I 8. MATLAB relational operators, conditional statements, and selection structures II 9. MATLAB loops 10. Summary

foundation of basic MATLAB applications in engineering problem solving, the book provides opportunities to explore advanced topics in application of MATLAB as a tool. An introduction to MATLAB basics is presented in Chapter 1. Chapter 1 also presents MATLAB commands. MATLAB is considered as the software of choice. MATLAB can be used .

I. Introduction to Programming Using MATLAB Chapter 1: Introduction to MATLAB 1.1 Getting into MATLAB 1.2 The MATLAB Desktop Environment 1.3 Variables and Assignment Statements 1.4 Expressions 1.5 Characters and Encoding 1.6 Vectors and Matrices Chapter 2: Introduction to MATLAB Programming 2.1 Algorithms 2.2 MATLAB Scripts 2.3 Input and Output

Fiction Excerpt 1: The Adventures of Tom Sawyer (retold with excerpts from the novel by Mark Twain) Saturday morning was come, and all the summer world was bright and fresh, and brimming with life. There was a song in every heart; and if the heart was young the music issued at the lips. There was cheer in every face and a spring in every step. The locust trees were in bloom and the fragrance .