EXERCISE 2 3X3 MATRIX DIAGONALISATION (part 1)
A' = S-1 . A . S (7)
The transformation
matrix S turns A into a diagonal matrix A'.
Once the transformation matrix S has been found, the eigenvectors of A
are contained in the columns of the transformation matrix on the right in Eq.
7 and in the rows of its inverse in Eq. 7, S-1. The eigenvalues A are the
diagonal elements of A' and the eigenvalue in the nth diagonal element
corresponds to the eigenvector in the nth column of S. Numerical diagonalisation is achieved by
bringing the matrix A gradually towards diagonal form using a sequence of
similarity transformations. For
symmetric matrices a sequence of orthogonal similarity transformations is
used. One such procedure is called Jacobi transformation. The routine jacobi_trans.c performs just such a transformation. Its
input is the matrix A, the outputs are the eigenvalues in array e[i] and the
eigenvectors in matrix v[i][j]. Note
that typedef statements have been used for declaration of scalars, matrices
and vectors. (For further details, see your course JS 3065 Computational
Methods).
|
12 EXERCISE 3 3X3 MATRIX DIAGONALISATION
Write a programme
which calls jacobi and solves the eigenvalue problem for
Calculate the
eigenvalues and eigenvectors of this matrix by hand and compare your
numerical results with your analytical result.
|
12.1.1 Exercise 4 Nearly Free Electron Energy Band Structure
The question of what
determines whether a material is an electrical conductor, insulator or
semi-conductor is of great importance in solid state physics. The free electron model, where electrons
are treated as an ideal Fermi gas, gives good insight into heat capacity and
thermal conductivity but fails to explain the electrical conductivity of
solids. It is found that the crystal
structure is most important in this problem as Bragg reflections of electron
waves within the crystal lead to the formation of energy band gaps, which in
turn determine the electrical conductivity of the solid. The Schrödinger equation for electrons in a
‘1-D crystal’ is
(8)
is the eigenfunction for wavenumber k, are
the allowed energies and V(x) is a periodic potential energy. A plot of versus k is called the band
structure. Since the potential energy
operator and the eigenfunctions both contain periodic functions they can be
expanded in Fourier series. We will
use the complex form of Fourier series to expand the periodic function f(x) =
f(x+na) (a = period, n is 0, 1, 2, ..)
(9)
In the nearly free
electron problem we choose to limit the expansion for the potential and
wavefunction such that only coefficients with –2 n 2 are nonzero. Solutions to the Schrödinger equation using
such a limited expansion for the wave function are quite accurate provided
the magnitudes of the potential energy Fourier components in the problem are
much less than the kinetic energies of the electrons. The expansions for the potential energy and
wave functions are
(10a)
(10b)
The right hand
equality in Eq. 10a is valid provided v1 = v-1 and v2 = v-2. We also choose v0 = 0. The factor exp[ikx] multiplying each term
in Eq. 10b is necessary to make k a Bloch eigenfunction. (See lecture notes from course JS 3014
Thermal and Electronic Properties).
When the potential and eigenfunction are substituted into Eq. 8, the
resulting set of linear equations is
Inspection of the
matrix equation above shows that its diagonal elements depend on wave number
k. An energy band calculation using
these equations consists of repeated construction of the matrix and
computation of its eigenvalues. The
notation Gn in the equations above means 2n/a. In 1-D the reciprocal lattice consists of
points given by k = Gn with n integer.
The equations are given in atomic units in which h bar = e = me =
1. It will be helpful if you choose
units for wavenumbers to be in units of /a so that k = ±1 correspond to the
Brillouin zone boundaries for the problem and Gn =2n.
|
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060. Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060. Email: kursusmatlab@gmail.com
13 EXERCISE 4
Write a programme
which contains a function which constructs the 5x5 matrix above as a function
of k. The programme should also call
the diagonalisation routine to obtain the eigenvalues of the matrix.
|
Use your programme
to obtain the bandstructure of a solid where all of the Fourier components of
the potential are weak (v-2 = v-1 = v1
= v2 = 0.1) and for a solid where some of the
Fourier components of the potential are strong (v-2 = 0.3 v-1 = 0.7 v1 = v2
= 0.1). Compare the band gaps calculated in your
programme at the Brillouin zone centre and at its edges with the result from
perturbation theory that the nth band gap is twice the nth Fourier component
of the periodic potential, e.g. the first gap at k = 1 (in units of /a) is
equal to 2 v1.
|
INTRODUCTION TO
MATLAB 10
WHAT IS MATLAB? 11
HISTORY OF MATLAB 12
AN INITIAL EXAMPLE 13
Population Growth 13
SOME FEATURES 15
RUNNING MATLAB 16
Startup Under Unix 16
Startup Under
Windows 95/98 16
To Exit 16
HELP & DEMOS 17
Through the Command
Window 17
Through the Help
Window 17
Through the Help
Desk 17
Demonstrations 17
CONTROLLING THE
ENVIRONMENT 18
A 2ND EXAMPLE 19
Final Approach 19
MAP GENERATION 20
MAP SMOOTHING 21
MAP CODE 22
mapGen 22
MapPlateau 23
PRINCIPLES OF “GOOD” PROGRAMS 25
REVIEW 26
MATLAB SYNTAX 27
SOME SIMPLE
CALCULATIONS 28
BASIC MATHEMATICAL
OPERATORS 29
EXPRESSIONS 30
VARIABLES &
ASSIGNMENT 31
THE ANS VARIABLE 32
Examining a
Variable’sValue 32
SEMICOLON, COMMA
& PERIOD 33
Semicolon 33
Comma 33
Period 33
LAYOUT CONVENTIONS 35
COMMENTS 36
USING COMMENTS 37
COMMENTS &
MATLAB HELP 38
SOME USEFUL
MATHEMATICAL FUNCTIONS 39
SCRIPT M-FILES 40
Basic Approach using
M-Files 40
Naming 40
MATLAB NAME SPACE 41
Matlab Search Path 41
REVIEW 42
MATLAB VARIABLES
& DATA TYPES 43
VARIABLES 44
IDENTIFIERS 45
MEANINGFUL
IDENTIFIERS 46
Some Examples 46
WEAK TYPING 47
IMPLICATIONS OF WEAK
TYPING 48
Advantages 48
Disadvantages 48
SPECIAL (BUILT-IN)
CONSTANTS & VARIABLES 49
COMPLEX NUMBERS 50
NAN & INF 51
STRINGS 52
MANAGING VARIABLES 53
clear 53
MANAGING WORKSPACE:
LOAD 54
MANAGING WORKSPACE:
SAVE 55
REVIEW 56
I/O IN MATLAB 57
BASIC INPUT 58
The Input Statement 58
INPUTTING STRINGS 59
BEHAVIOUR OF INPUT
STATEMENT 60
MICRO: AMOEBA
EXPANSION 61
MICRO RUN 62
BASIC OUTPUT 63
The disp Statement 63
THE FORMAT COMMAND 64
FORMAT EXAMPLES 65
MORE 66
FILES IN GENERAL 67
Opening &
Closing Files 67
FPRINTF 68
CONTROLLING FPRINTF 69
FSCANF 70
PROJECTILE EXAMPLE 71
PROJECTILE CODE 72
PROJECTILE RUN 74
PROJECTILE PLOT 75
REVIEW 76
ARRAYS IN MATLAB 1 –
VECTORS 77
MOTIVATION 78
VISUALISING A 1D
ARRAY (VECTOR) 79
MATLAB & ARRAYS 80
VECTOR CREATION 81
VECTOR CREATION
EXAMPLE 82
ADDRESSING THE
ELEMENTS OF A VECTOR 84
COLUMN VS. ROW
VECTORS 85
COLUMN VS ROW
EXAMPLE 86
SCALAR-ARRAY MATHEMATICS 87
EXAMPLE CEL2FAR.M 88
CEL2FAR RUN 89
ARRAY-ARRAY
MATHEMATICS 90
EXAMPLE – BOUNCING.M 91
BOUNCING.M CODE 92
REVIEW 94
MATLAB ARRAYS 2 –
MATRICES 95
2D(+) ARRAYS –
MOTIVATION 96
VISUALISING 2D
ARRAYS 97
VISUALISING 2D
ARRAYS EXAMPLE 98
CREATION 99
CREATION EXAMPLE 100
MATHEMATICS OF
MATRICES 101
MATHEMATICS EXAMPLE 102
ADDRESSING &
MANIPULATION 105
ADDRESSING &
MANIPULATION EXAMPLE 106
EXAMPLE – NETWORK
TRAFFIC 109
TRAFFIC CODE 110
TRAFFIC EXAMPLE
PLOTS 112
SPECIAL MATRICES 113
SPECIAL MATRICES EXAMPLE 114
ARRAY SIZES 115
ARRAY SIZES EXAMPLE 116
MULTI-DIMENSIONAL
ARRAYS 117
LINEAR EQUATIONS 118
LINEAR EQUATIONS
EXAMPLE 119
REVIEW 120
MATLAB RELATIONAL
OPERATORS & BASES 121
MOTIVATION -
RELATIONAL OPERATORS 122
BOOLEAN OPERATIONS 123
EXAMPLE – PIECEWISE
FUNCTIONS 127
PIECEWISE FUNCTION
EXAMPLE 128
NAN & EMPTY
ARRAYS 129
BASE CONVERSION 130
BASE CONVERSION
EXAMPLE 131
BIT LEVEL OPERATIONS 132
REVIEW 133
MATLAB SELECTION
STATEMENTS (IF & SWITCH) 134
MOTIVATION 135
SIMPLE IF 136
EXAMPLES – SIMPLE IF 137
IF-ELSE 138
EXAMPLE – IF-ELSE 139
IF-ELSEIF-… 140
EXAMPLE – IF-ELSEIF… 142
TRUTH TABLES &
COMPOUND IFS 143
SWITCH 145
EXAMPLE –SWITCH 147
REVIEW 148
LOOPS IN MATLAB 149
MOTIVATION 150
DEFINITE ITERATION
(FOR LOOP) 151
FOR LOOP SCHEMATIC 152
FOR LOOP EXAMPLE 153
FOR LOOP ADDITIONAL 154
INDEFINITE ITERATION
(WHILE LOOP) 155
WHILE LOOP SCHEMATIC 156
WHILE LOOP EXAMPLES 157
WHILE VS IF 158
GENERAL LOOPS &
BREAK 159
BREAK SCHEMATIC 160
COMBINED (MAJOR)
EXAMPLE 161
WORMS RUN 164
LOOP USAGE
GUIDELINES 165
LOOP CONTROL 166
COMMON TYPES OF
LOOPS 167
LOOPS VS IMPLICIT
VECTORISATION 168
LOOPS VS. VECTOR
EXAMPLE 169
REVIEW 170
EFFICIENCY &
ERRORS 171
MOTIVATION 172
NUMERIC LIMITATIONS 173
Overflow 173
Underflow 174
ROUNDING &
CANCELLATION 175
Rounding (Precision) 175
Cancelation (Order
of Precedence) 175
WORK-AROUNDS FOR
NUMERIC LIMITATIONS 176
For Instance:
Comparing Two Numbers 176
ERRORS &
DEBUGGING IN MATLAB 177
MATLAB DEBUGGER 178
ORDER OF AN
ALGORITHM 179
TIMING IN MATLAB 180
PERFORMANCE
PROFILING IN MATLAB 181
PROFILER EXAMPLE 182
GUIDELINES FOR
EFFICIENCY 183
Special Cases and
Redundant Checking 183
EFFICIENCY:
REDUNDANCY & FUNCTIONS 184
Avoid Redundant
Computations 184
Minimise Costly
Function Usage 184
EFFICIENCY: ARRAYS 185
Minimise Array Referencing 185
Time vs Space 185
EFFICIENCY: LOOP
TERMINATION 186
Avoid Late
Termination of Loops (Needless Calculations) 186
EFFICIENCY –
COMPLICATING ISSUES 187
LOOPING VS IMPLICIT
VECTORISATION 188
TIMING EXAMPLE 189
SHELL1 – LOOPING
WITHOUT EFFICIENCY 190
SHELL2 – LOOPING
EFFICIENTLY 191
SHELL3 – IMPLICIT
VECTORISATION 192
REVIEW 193
BASICS OF MATLAB
FUNCTIONS 194
MOTIVATION 195
CALLING FUNCTIONS 196
OVERVIEW OF FUNCTION
CALL & RETURN PROCESS 197
ON MATLAB'S IN-BUILT
FUNCTIONS 198
WHAT MAKES A GOOD
FUNCTION – SOFTWARE ENGINEERING PRINCIPLES 199
FUNCTION DECLARATION
SYNTAX 200
A FIRST FUNCTION 201
EXAMPLE: TIMING OF
FUNCTIONS 202
COMMENTS &
FUNCTIONS 203
TOP-DOWN VIEW OF
FUNCTION DESIGN 204
BOTTOM-UP VIEW OF
FUNCTIONS 205
THE BLACK BOX
PARADIGM 206
PARAMETERS – INPUT
CHANNEL 207
RETURNED VALUES –
OUTPUT CHANNEL 208
EXAMPLE –
DESCRIPTION 209
EXAMPLE RESULTS 210
EXAMPLE – DAILYTEMPS 211
EXAMPLE – GETTEMPS 212
EXAMPLE –
PROCESSTEMPS 213
EXAMPLE – TEMPTABLE 215
EXAMPLE – TEMPPLOT 217
REVIEW 218
FURTHER MATLAB
FUNCTIONS 219
FORMAL VS. ACTUAL
PARAMETERS & OUTPUTS 220
PARAMETER
ASSOCIATION 221
PARAMETER
ASSOCIATION EXAMPLE 222
PASS BY VALUE &
PASS BY REFERENCE 224
PASS BY VALUE
EXAMPLE 225
SCOPE RULES &
WORKSPACES 226
SCOPE EXAMPLE 227
RUN-TIME STRUCTURE
& THE STACK 228
RETURN, ERROR &
WARNING 229
NARGIN &
VARIABLE INPUTS 230
NARGOUT &
VARIABLE OUTPUTS 231
NARGIN & NARGOUT
EXAMPLE 232
GLOBAL VARIABLES 237
EFFICIENCY ISSUES 238
VARARGIN &
VARARGOUT 239
SUB-FUNCTIONS 240
REVIEW 241
GRAPHICS & OTHER
MATLAB FEATURES 242
MOTIVATION 243
2D GRAPHICS –PLOT 244
AXES & LABELS 245
PRINTING FIGURES 246
MULTIPLE FIGURES
& SUB-PLOTS 247
OTHER 2D PLOTS 248
MULTIPLE PLOTS
EXAMPLE 249
2D PLOTS - OUTPUT 252
ADDING TEXT 254
3D GRAPHICS – LINE 255
3D GRAPHICS –
SURFACE 256
3D SURFACES EXAMPLE 257
POLYNOMIALS 258
INTERPOLATION &
SPLINES 260
OPTIMISATION 262
INTEGRATION,
DIFFERENTIATION & ORDINARY DIFFERENTIAL EQUATIONS 263
DATA-STRUCTURES 264
OBJECT ORIENTED 266
GUI DESIGN 267
TOOLBOXES 268
REVIEW 269
3D MAPS IN MATLAB, A
CASE STUDY 270
PROBLEM
SPECIFICATION 271
BASIC APPROACH &
DATA STRUCTURE 272
MAP CREATION –
ALGORITHM 274
MAP CREATION –
EXAMPLE 275
CREATED MAP 276
MAP CREATION – CODE 277
MAP
SMOOTHING/WEATHERING – ALGORITHM 279
MAP SMOOTHING –
EXAMPLE 280
SMOOTHED MAP 281
MAP SMOOTHING – CODE 282
CRATER ADDITION –
ALGORITHM 286
CRATER ADDITION –
EXAMPLE 287
CRATERED MAP 288
CRATER ADDITION –
CODE 289
RIVER ADDITION –
ALGORITHM 292
RIVER ADDITION –
EXAMPLE 293
MAP WITH RIVER 294
RIVER ADDITION –
CODE 295
REVIEW 301
14 INTRODUCTION TO MATLAB
• MATLAB is a
powerful engineering environment and language
- powerful tool in engineering
problem solving, data analysis, modeling and visualisation
- useful throughout your degree
& used in other courses
• Matlab is the
vehicle used by this course to teach:
- problem solving by computer
- programming
• Today’s lecture is
introductory:
- “driving” Matlab
- illustration by example
Reference:
For
Engineers (Ch. 1 & 2)
Mastering
(Ch. 2, 3 & 34)
User’s
(Ch. 1, 23 & “A Quick Overview”)
14.1 What is Matlab?
MATLAB: MATrix LABoratory
• “High performance
language for technical computing”
• Interactive
environment incorporating:
- programming language
- mathematical calculations
(computation)
- data visualisation
- large number of inbuilt routines
corresponding to many mathematical, engineering & science problems
• Typical uses
include:
- mathematical calculations
- engineering & scientific
problem solving
- modeling & simulation
- data analysis &
visualisation
• Basic data
structure (unit of computation) of an array/matrix
- vector operations
- natural expression of many
engineering & scientific problems
14.2 History of Matlab
• First introduced
at Stanford Uni in 1979
- initially an interactive shell
from which to call FORTRAN routines
• Later MathWorks
was formed to market Matlab.
|
• An evolved
language
- initially a collection of things
felt to be necessary
- little top-down design
- “Like every other scripting
language, Matlab began as a simple way to do powerful things, and it has become
a not-so-simple way to do very powerful things.”, Webb & Wilson, Dr.
Dobb’s Journal, Jan 1999
• Heavily used by
universities world wide in their engineering and science faculties for
teaching
- (see links off
course homepage)
• Used by scientists
and engineers in research, development and design
14.3 An Initial Example
14.3.1 Population Growth
A colony of
micro-organisms grows at such a rate its population doubles every 14.3 hours.
|
Given an initial
population of 1000 organisms, calculate the population on an hourly basis for
the period of two days.
|
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060. Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060. Email: kursusmatlab@gmail.com
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% amoeba.m
% Matlab example to show
problem solving. A
% species doubles its
population every 14.3
% hours. Given an
initial population of 1000
% determine its
population hourly
% for the first two
days
% Author: Spike
% Date: 10/2/1999
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
% Initial “setup”
work %
%%%%%%%%%%%%%%%%%%%%%%%%
initialNum = 1000; % Initial
population
doublePeriod = 14.3; % Time in hours to
% double population
interval = 0:48; % Two days on an hourly
% basis
%%%%%%%%%%%%%%%%%%%%%%%
% Perform
calculation %
%%%%%%%%%%%%%%%%%%%%%%%
population =
initialNum*2.0.^(interval/doublePeriod);
%%%%%%%%%%%%%%%%%
% Output values %
%%%%%%%%%%%%%%%%%
combined = [interval
; population];
disp('Micro Organism
Population');
disp('Hour Population');
fprintf('%d\t%6.0f\n',combined);
1st Example (Cont)
%%%%%%%%%%%%%%%%
% Plot results %
%%%%%%%%%%%%%%%%
plot(interval,population,'-+');
xlabel('Hours');
ylabel(‘Population’);
>> amoeba
Micro Organism
Population
Hour Population
0
1000
1
1050
2
1102
14
1971
15 2069
47
9759
48 10244
14.4 Some Features
• Powerful
computation engine
• 3rd generation
scripting (programming) language
- functions & argument passing
- iteration & slection
• Implicitly
vectorised operation
• Powerful 2D and 3D
plotting capabilities
• Diverse and
powerful inbuilt functions
- linear algebra
- polynomials
- fourier analysis
- integration &
differentiation
- differential equations
• Add-on toolboxes
for specific problem domains
• multi-media
capabilities
- GUI builder
- Movies & sound
14.5 Running Matlab
14.5.1 Startup Under Unix
Type matlab at the
shell prompt:
$ matlab
Or through the
workspace menu on octarine
14.5.2 Startup Under Windows 95/98
From program menu
select Student Edition of Matlab
14.5.3 To Exit
Type quit (or exit)
in the command window:
>> quit
Or through Matlab’s
File menu.
|
14.6 Help & Demos
• Matlab has a
extremely comprehensive help
14.6.1 Through the Command Window
help (e.g., help mean). Most general form of
help. Without options lists all help topics. If option then provides help for
that particular command. Always start with this.
|
lookfor (e.g., lookfor 3d) Look for commands that
are relevant to the topic specified.
|
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060. Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060. Email: kursusmatlab@gmail.com 14.6.2 Through the Help Window
• Window based
version of the above
• Invoked from the
help menu or by typing helpwin in the command window.
|
14.6.3 Through the Help Desk
• Web browser based
help, invoked from menu or by entering helpdesk or doc in the command window.
|
14.6.4 Demonstrations
• Large series of
examples: demo command
14.7 Controlling the Environment
• A list of “meta”
commands useful for controlling the Matlab environment and execution
<cntrl-c> Terminate
currently executing command. Useful if stuck in an infinite loop.
|
clc Clear
the screen and home the cursor.
|
KURSUS MATLAB ONLINE Skripsi, Tesis, DISERTASI 081219449060
Selasa, 13 Januari 2015
KURSUS MATLAB ONLINE Skripsi, Tesis, DISERTASI 081219449060
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar