Selasa, 13 Januari 2015

Design of IIR-filter from filter specification



                              Pole-zero plot                                  Magnitude spectra |H(f)|
                               

Laboratory tasks
IIR filter
 The program MKIIR is used for interactive IIR filter design. You can place poles and zeros in the pole-zero plane and then show the impulse response, magnitude spectra and phase function for the digital system. The program can also design filters from specification of requirements of magnitude spectra. A set of standard filters are also included in the program.


Task 1:  Relation between poles and filter spectrum
Type MKIIR to start the program at the Matlab prompt.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com
Place a pole or a pair of complex poles in the z plane and check
the result.
Press first Replace last. Move the pole inside the unit circle and check the result.
Specially, look at  the relation of the magnitude and angle of the poles and the
magnitude spectra and the impulse response.

Release  Replace last.


Task 2: Design of IIR-filter from filter specification
Choose poles and zeros for fulfilling the demands below based on your experience from task 1.

Press  Import Workspace and open the file irspec1.mat
to load the specifications into MKIIR.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com


Now, choose poles and zeros to  fulfill the requirements.
You can ave your filter with  Export Workspace  and choose a file
name  (i.e.filter1.mat. Then press Import filter to reload the filter.

Optional task
Compare with standard filter solutions.
Stop the program MKIIR, press Exit.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com

Task 3  Notch filters
Now, you will examine notch filters. The system function for both the FIR filter and the IIR filter are given below

with       the frequency which shall be cancelled.  Plot the magnitude spectra for the filters with varying position of the  poles and zeros using the program MKIIR .

Alternatively, you can use Matlab direct and typing your system function above (FIR).

f0=0.2; r=0.95; w0=2*pi*0.2;  f=0:.01:1; z=exp(j*2*pi*f);
Hfir=1-2*cos(w0)*z.^(-1)+z.^(-2);subplot(211), plot(f,abs(Hfir));
Hiir=Hfir./(1-2*r*cos(w0)*z.^(-1)+r^2*z.^(-2)); subplot(212),plot(f,abs(Hiir));

Task 4: Filter music signals
In this task, you shall cancel sinusoids added to music files. Sampling rate  Fs=8000 Hz, stereo.

Call  global S, jukebox, song=S;  and choose a song from the list. You must choose one of the first 5 for testing in the DSP. The variable S will contents 100000 samples from the song and it is stored in the variable 'song' for future use.  Listen to the song (small part)
soundsc(song,8000);
Use Windows "Sound recorder"  to listen to the whole song. Avoid long files in
Matlab due to difficulties to stop the sound outputs in Matlab.

Now, use mkspa to determine the frequencies of the sinusoids. Press  PEAK and use the mouse to point at peaks in the spectrum. The frequencies are multiples of 10 Hz.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com
Write down the frequencies for the peaks of your song.
Press Exit to stop mkspa.

Now, you shall determine a notch filter which cancel the sinusoids. Try both FIR and IIR filters. Type your choice of poles and zeros in Matlab and put them into vectors.
Then, determine the A and B polynomials.
Example:             Fs=8000; F1=      ;   F2=   ;     F3=     ;
                        z1=exp(-j*2*pi*F1/Fs); z2=conj(z1);
                              z3=exp(-j*2*pi*F2/Fs); z4=conj(z3);
                              z5=exp(-j*2*pi*F3/Fs); z6=conj(z5);
                              Z=[z1,z2,z3,z4,z5,z6];
                              P=0.9*Z;
                              B=poly(Z)
                              A=poly(P)
                              zplane(B,A)                   % check pole-zero plot
                              plot also the magnitude spectrum for your filter (see help freqz)
f=0:.01:1; w=2*pi*f; H=freqz(B,1,w); plot(f,abs(H));   %FIR
f=0:.01:1; w=2*pi*f; H=freqz(B,A,w); plot(f,abs(H));   %IIR
Notice:  You must use  j for the imagine part. Test the filter using  MKIIR.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com

 
Test the filter in Matlab
You have already a small part of the song in the global variable 'song'. 
If not,  reloaded using:
song=wavread('ssilence',[1 100000]);  % load 100 000 value
Listen to the disturbed song (no filtering)
soundsc(song, 8000);          % listen Fs=8 kHz
Filter the song with your filters, both the FIR and the IIR filter and listen.

y0=filter(B,1,song);   soundsc(y0, 8000); 
y1=filter(B,A,song);  soundsc(y1, 8000); 
Did your filters fulfill the requirements?

Appendix:  Program descriptions
IIR filter design, MKIIR
MKIIR can be used for interactive filter design from poles and zeros.


Function
Import Workspace:          Read filter specifications from file.
Export Workspace:          Save filter specifications on file.
Set filter specs:  Input filter specifications.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com
Filter coeffs:                      Input  filter coefficients.
Help:                                    Not implemented yet.
About:                                 Program version.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com
Reset:                                  Resets poles and zeros but not filter specifications.

Exit:                                     Exits and save workspace to the file current.mat .
Add pole:                            Place pole, press left mouse button, ends with
right mouse button.

Delete pole:                       Place cursor over pole, press left mouse
button to delete, ends with right mouse button.

Add zero:                            Set Add pole
Delete zero:                       See delete pole
Move:                                 See add pole
Import filter:                      Import of standard filters from Matlab
Signal Processing Toolbox.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com
Magnitude:                        Magnitude function.
Phase:                                Phase function.
Impulse:                             Impulse response.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com
Replace last:                     Replace last
Reciproc Zeros:
HighPass:                            High pass filter   |H(f)|_{| f=0.5}=1,
Low pass filter    |H(f)|_{| f=0}=1.
Zoom:                                 Zoom.
Unwrap;                            Phase Unwrap Phase.
Focus:  
Radius
Adjust Gain:                       Adjust Gain  in dB.


Spectral analysis, MKSPA
MKSPA is used to analyze the spectra in the sound
files.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com

Functions
Window:              Window functions.
FFT length:          FFT length.
Overlap:               Number of overlapping segments
Fs(Hz):   Sampling frequency.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com
Zoom:                  Activate/deactivate  Matlab zoom
Analyze:               Analyze
Exit                       End the program.


Calculus 3, Math 203 Section EE
Instructor: Giancarlo Paolillo
Email: apaolillo@ccny.cuny.edu (by far the best way to reach me)
Office: 3/207D, tel. 650-6273
Office Hours: T, Th. 6:30PM – 7:30PM, Wed. 3:30 – 4:30PM and by appointment
Places and Times:   M, W 2:00PM – 3:15PM in NA 6/113
                              F 2:00PM -2:50PM in NA 1/511E and 3:00PM – 3:50PM in NA 1/511 A                                                                                                       
Text: Calculus, by Minton and Smith, 3rd edition, McGraw – Hill
Material to be covered:
Section                        Topics                                       Approximate Lecture Hours
                                                                                       ( 1 lecture hour = 50 minutes)
9.1                           Sequences                                                               1
9.2                           Series                                                                      1.5
9.3                           Integral Test/Comparison Tests                              2.5
9.4                           Alternating Series                                                   1.5
9.5                           Absolute Convergence,ratio test (omit root test)    1.5
9.6                           Power Series                                                           1.5
9.7                           Taylor Series                                                            2
9.8                           Applications of Taylor Series                                  2
11.1                       Vectors in the plane                                                 1
11.2                       Vectors in space                                                       1
11.3                        Dot Product                                                             1
11.4                        Cross Product                                                          2
11.5                        Lines and Planes                                                     2.5
11.6                        Quadric Surfaces                                                    2
12.1                        Curves in Space                                                      1
12.2                        Derivatives of vector functions (omit integrals)     1
12.6                        Parametric Surfaces (covered again in lab 7)         1
13.1                        Functions of Several Variables                              1.5
13.2                        Limits and continuity                                              2
13.3                        Partial Derivatives                                                  1
13.4                        Tangent planes, differentials                                  2
13.5                        Chain rule                                                               2
13.6                        Directional derivative, gradient                              2
13.7                         Extrema                                                                  2
14.1                         Double integrals                                                     2.5
14.2                         Applications of double integrals                            2
14.3                         Double integrals in polar coordinates                    1.5
14.4                         Surface Area                                                          1.5
14.5                         Triple integrals                                                       2
14.6                         Triple integrals in Cylindrical Coordinates           .75
14.7                         Triple integrals in Spherical Coordinates              1.25
                                           
Course Format: 4 hours per week lecture/recitation and 1 hour/week working in the Artino computer lab. Students should gain some proficiency in Matlab software.
The Math Department Website is located at http://math.sci.ccny.cuny.edu
There you will find assorted information including old departmental final exams and under the link to Math 203, you’ll find the Matlab notes we’ll be using in the lab.

Blackboard: I will be using the Blackboard online course management tool for this course, posting homework assignments and reminders of when tests will occur. Also, practice problems and their solutions for the in-class tests will also be posted on Blackboard. All of you should be on Blackboard as soon as possible. See the Computer Help Desk on the first floor of NAC if you have difficulties.

Webwork: Starting with the material in Chapter 11 onward, I will be assigning problems using an online homework system  called Webwork. More information will be given about this when we get to it. If your quiz scores are low, you can boost your hw/quiz average by putting in a greater effort for the online problems. I’ll have ways of seeing your effort.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com

Grades: The grade will be based on in-class tests, quizzes, homework, participation (for which attendance is a component),computer homework, the Matlab final, and the course final exam. The breakdown is as follows:
Homework/Quizzes/Participation*:          14%
4 in-class tests:                                           36%
Labwork(including homework and final:  10% (5% each)
Final Exam                                                  40%
*Participation necessitates your punctual presence in class. You will be expected to read over the sections about to be covered before the lecture, enabling you to understand the lecture better and to have better questions in class. You must keep pace with the homework assignments as well. The quizzes will be closely based on the homework and what I do in class when they aren’t based on review material from earlier courses (e.g. parametric equations, polar coordinates, or improper integrals). The lowest grade on the four in-class tests will be dropped if and only if you have no more than four unexcused absences.

Attendance and Punctuality: If you are more than 15 minutes late, you will be marked as absent. If you are more than 5 minutes late, you will be marked late. Three lates will count as one absence. If you have a legitimate reason for being late or missing class (e.g. illness or job related), send me an email preferably prior to the class and provide some sort of documentation (such as a doctor’s note or a letter from your employer) to me when you see me next. Otherwise I will count it as an unexcused absence. In addition to becoming ineligible for having your lowest test grade dropped, excessive unexcused absences will result in up to 5 points (out of 100) being deducted from your final grade.
Tutoring: The Math Department provides tutoring in MR 418S, i.e. in the Marshak Science building on the fourth floor. The hours are M, T, Th. 12-7pm, W 10am-4pm,
and F 10am-3pm.

Make-up Tests and Quizzes: Only under extraordinary circumstances will I give a make-up test. Usually, I will count a missed test as your lowest test score – assuming you haven’t become ineligible for that through absences. I won’t give make-up quizzes.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com

Academic Integrity: Any form of cheating will be dealt with by sanctions ranging from a 0 on the test in question to formal disciplinary proceedings. See the official statement at the following URL: http://www1.cuny/portal_ur/content/2004/policies/image/policy.pdf
COURSE LEARNING OUTCOMES
 COURSE LEARNING OUTCOMES  After taking this course, the student should be able to                                                                                                                                                                                                                                                                                                                                                
1. model spatial problems with vectors, lines, planes, curves and surfaces in space                a,b,c 2. use differentiation for vector-valued functions to compute tangent lines                                  a,b,c 3. use differentiation for multivariate functions to find extrema and rates of change                 a,b,c 4. set up and evaluate multiple integrals for regions in the plane and in space                                             a,b 5. use iterated integrals to measure areas, compute volumes and find centers of mass                              a,b,c 6. analyze infinite series for convergence using a range of tests                                                                       a,e1,e2 7. find intervals of convergence for power series and represent functions with power series                     a,b,c,e1,e2 8. use MATLAB to analyze and solve geometric, computational, and symbolic problems for topics above             d 
 Key to the above:
 a. perform numeric and symbolic computations b. construct and apply symbolic and graphical representations of functions c. model real-life problems mathematically d  use technology appropriately to analyze mathematical problems e. state (e1) and apply (e2) mathematical definitions and theorems f. prove fundamental theorems g. construct and present (generally in writing, but, occasionally, orally) a rigorous mathematical argument.         
Aerospace Practicum
Introduction to MATLAB Lecture #2
Based on Chapter 15 of Engineering Fundamentals: An Introduction to Engineering
By: Saeed Moaveni © 2005 Nelson
Students provided with a copy of Chapter 15
Finish any sections not completed from session 1 or answer any questions from last laboratory lecture
Example 1: Review the difference between matrix multiplication and element-by-element multiplication
A=[1 2; 3 4];
B=[2 3; 4 5];
True matrix multiplication:
C=A*B
C=B*A
Element by element multiplication:
C=A.*B
C=B.*A
Example 2: Often interested in multiplying arrays of numbers element by element
Clear all;
A=[1 2 3 4 5];
B=[6 7 8 9 10];
C=A*B = ?
C=A.*B =
C=B.*A =
We will use this again in various examples today
Introduce: ones, zeros, eye
Example 2 (Example 14.11): Curve Fitting with MATLAB
Note: Instead of entering all the x-values, since they are incremented by 0.5, you can quickly set the x-range as: x=0:0.5:3.

Also have the students plot the x,y data and the polynomial curve fit on a single plot. This will give more practice with plotting as well as labeling the plots and adding a legend. I also showed how to change the symbols of the poly fit to circles and make them red in color. A sample of how this might be done is included below, but you can do it multiple ways:
x=0:0.5:3;
y=[2 0.75 0 -0.25 0 0.75 2];
Coeff=polyfit(x,y,2)
y_fit=Coeff(1).*x.^2+Coeff(2).*x+Coeff(3);
plot(x,y,x,y_fit,'ro');
xlabel('X Data');
ylabel('Y Data');
title('Data and Second Order Polynomial Fit Comparison');
legend('X-Y Data','Second Order Polynomial Fit');
grid;
Repeat example using polyval
Example 3: Return to Normal Inlet shock wave example now using MATLAB, recall that this example was completed last week using Excel
3.1: single gamma = 1.4
3.2: introduce for loops to generate 2-D matrix with variable gamma, introduce legend command
3.3: show how to select individual elements, columns and rows and how to generate a larger matrix of M0 and M1 for each gamma
3.4: use of colon in generating 2-D matrix of data
In-Class Examples, see hand-out:
In-Class Example 1:Excel and MATLAB to generate circles, key point is to introduce axis equal
In-Class Example 2: Illustration of 3-D plotting for helix (change helicity?)
In-Class Example 3: Introduction to functions, program to generate unit vector from longitude and latitude coordinates.
Matrix Computing
This practical introduces the following:
             LU decomposition for the solution of a set of linear equations
             Comparison of 32 bit, 64 bit and 80 bit calculations of the Hilbert matrix
             Solution of eigenvalue problems using the method of Jacobi rotation
Introduction
Many problems in computational physics can be reduced to linear algebra problems.  In this laboratory you will use several fundamental techniques of computational linear algebra to solve physics problems common in many different areas of science.  In order to solve the problem with some variations you will need to solve a system of linear equations by Gauss-Jordan Elimination, ‘LU decomposition plus back substitution’, matrix inversion and matrix diagonalisation. 
9            
10           SOLVING A SET OF LINEAR EQUATIONS
A common problem in physics is the task of solving a set of linear equations
a11 x1 + a12 x2 + a13 x3 + a14 x4 + a15 x5 = b1
a21 x1 + a22 x2 + a23 x3 + a24 x4 + a25 x5 = b2
a31 x1 + a32 x2 + a33 x3 + a34 x4 + a35 x5 = b3
a41 x1 + a42 x2 + a43 x3 + a44 x4 + a45 x5 = b4
a51 x1 + a52 x2 + a53 x3 + a54 x4 + a55 x5 = b5
In matrix form this becomes A . x  = b with A, b and x given by
a11  a12  a13  a14  a15                  b1                          x1
a21  a22  a23 a24  a25                   b2                          x1
a31  a32  a33  a34  a35                  b3                          x1
a41  a42  a43  a44  a45                  b4                          x1
a51  a52  a53  a54  a55                  b5                          x1
The standard method for solving for the vector x is Gaussian elimination.  A particularly useful formulation in terms of numerical treatment is called LU decomposition. Here the matrix A is written as the product of a lower triangular matrix L and an upper triangular matrix U, A = L . U.  Note that the vector b does not enter here. This means that once the decomposition has been performed, it can be applied to solve A . x = b for any value of b.  The determinant of A is simply given by the product of the diagonal elements of L.  For a detailed discussion of both Gaussian Elimination and LU decomposition see DeVries pp 119-131 and your lecture notes from course 342, Numerical Methods.  The function lu_solver.c (Appendix A) takes as input the matrix A and the vector b (and specification of the array sizes). It returns the solution x and the determinant. In the course of the decomposition A is overwritten by L and U (note that the rows become interchanged).
Exercise 1            Solution of Linear Equations by LU Decomposition
Write a programme that solves the equation A . x = b for
                                                                                                                        (1)
using LU decomposition and solve the problem yourself on paper.  Compare results of each method of solution.  The main() function (here called lin_eq.c) contains the value of the matrix elements and the vector b. It should call the external function lu_solver.c. Thus use as header:

#include "lu_solver.h"
#include <math.h>
extern void lu_solve(double a[][],double x[],double b[], double det, int ndim, int n);
Exercise 2            Hilbert Matrices
The nxn Hilbert matrix is the square matrix with elements
                                                                                                                                                      (2)
For example, the 3x3 Hilbert matrix is
                                                                                                                        (3)
The Hilbert matrix has the property that its determinant decreases rapidly with increasing matrix dimension.  Using your LU decomposition program, solve the equation H . x = b with bi = i, e.g. for the 3x3 matrix b = (1,2,3) and compute the determinant of H.  The numerical accuracy of your program may be checked by setting
                                                                                                                                                      (4)
which has the solution x = (1,1,1).  Up to what values of n do your computations agree with this? How does it change when you define the Hilbert matrix as a) float b) double c) long double.  Using long double compute the determinant as a function of n (for a reasonable range of n) and plot the data.  The format statements in the fprintf command should be %f, %lf and %Lf, respectively.

11           EIGENVALUE PROBLEMS
The eigenvalue problem is defined by the equation
                                                                                                                                                      (5)
where A is a matrix of constants and xn and n are the nth eigenvector and eigenvalue solutions of the problem.  In all, if A is an NXN matrix, there are N eigenvectors and eigenvalues.  The problem may be solved by computing the following determinant
                                                                                                                                                      (6)
where I is the unit matrix of the same dimension as A.  Evaluation of this determinant for an NxN matrix A results in an Nth order polynomial in .  This is called the characteristic equation or secular equation for the matrix A.  Its N roots give the eigenvalues of A, n. Obviously this is challenging for n > 2, so one generally adopts a numerical solution for larger matrices.  A square matrix A can be diagonalised by a unitary transformation (see lecture notes from course Numerical Simulations of Physical Systems MA 342 or Linear Algebra and its Applications, G. Strang S-LEN 512.5 L6*2).
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 0822 9988 2015.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Kami memberikan jaminan dan garansi dilatih hingga bisa dengan biaya 4-6 juta selama 10 kali pertemuan. 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) 0822 9988 2015.   Email: kursusmatlab@gmail.com

Tidak ada komentar:

Posting Komentar