Download presentation

Presentation is loading. Please wait.

Published byJoel Leising Modified over 3 years ago

1
1.3 ARRAYS, FILES, AND PLOTS + FOURIER SERIES BY MR. Q

2
ARRAYS A set of numbers in a specific order or pattern 1 x n dimensional matrix In Matlab, you must always define arrays: To input y=f(x) you must Define x Define y as a function of x using the hundreds of functions available in Matlab

3
ARRAYS Define y=sin(x) on the interval [0, 2π] Is it continuous? How accurate should you have it? How ‘big’ is the array(s)? What is the 10 th value?

4
FILES

5
Must define independent and dependent variables Plot(independent, dependent,…, ‘+’) title (‘ ‘) xlabel (‘ ‘) ylabel(‘ ‘) gtext(‘ ‘) [x,y] ginput( n ) grid PLOT

6
Combination of arrays n x m dimensions Constructed using a semi colon between rows Ax=b x=? Solve using Matlab 2x+2y+3z=10 4x-y+z=-5 5x-2y+6z=1 MATRICES

7
Used: Originally to solve heat equation Differential Equations- Eigensolutions Electrical Engineering Vibrational Analysis Signal Processing, etc. Breaks down repeating, step, or periodic functions into a sum of sine and cosine FOURIER SERIES

9
P1.23 FT APPROXIMATION Consider the Step Function The Fourier Transform for the above Function Taking the First FOUR Terms of the Infinite Sum

10
How can we plot f(x)? Solution 1 x1=[-pi,0] f1= [-1,-1] x2=[0,pi] f2=[1,1] OR Solution 2 x0=[-pi,-1e-6,1e-6,pi] f0=[-1,-1,1,1] GRAPHING THE FUNCTION

11
Solution 1 plot(x1,f1,x2,f2);grid; title(‘f(x)’);xlablel(‘x’) Solution 2 plot(x,f);grid;title(‘f(x )’);xlabel(‘x’); PLOT THE FUNCTION

12
How can we graph? Solution 1 x=-pi:0.01:pi; f=4/pi(sin(x)/1+sin( 3*x)/3+sin(5*x)/ 5+sin(7*x)/7); Solution 2: ftot=zeros(1,length(x) for k=1:2:7; fc=sin(k*x)/k; ftot=fc+ftot; end GRAPHING THE APPROXIMATION

13
Let’s make a program for solution 2 and plot all on same axis! function fourier(n) x=-pi:0.01:pi; f1=[-1,-1,1,1]; x1=[-pi,-1e-6,1e-6,pi]; ftot=zeros(1,length(x)); for k=1:2:n; fc=sin(k*x)/k; ftot=ftot+fc; end f=4/pi*ftot; plot(x,f,x1,f1) CAN WE GET A BETTER APPROXIMATION?

14
THE HEAT EQUATION

Similar presentations

Presentation is loading. Please wait....

OK

Working with Arrays in MATLAB

Working with Arrays in MATLAB

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on natural and artificial satellites wiki Conceptual architecture view ppt on android Ppt on forward rate agreement calculation Ppt on margin trading Ppt on product marketing strategies Ppt on networking related topics on typhoons Ppt on polynomials of 92 Ppt on service oriented architecture Ppt on bond length table Ppt on social networking free download