This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
vpde_lecture22 [2020/03/25 08:24] trinh |
vpde_lecture22 [2020/03/26 13:42] (current) trinh |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== MA20223 Lecture 22 ====== | ====== MA20223 Lecture 22 ====== | ||
- | //This lecture is about terminology but it is important not to be bogged down by terminology. You will practice by doing!// | + | //This lecture is about terminology but it is important not to be bogged down by terminology. You will practice by doing! |
- | **Edit:** Still editing this one and waiting for videos to finish processing. | + | |
+ | < | ||
+ | <iframe width=" | ||
+ | </ | ||
===== An example ===== | ===== An example ===== | ||
Line 43: | Line 46: | ||
where bn will be the Fourier sine coefficients of the odd 2π extension of f(x) on [0,π]. | where bn will be the Fourier sine coefficients of the odd 2π extension of f(x) on [0,π]. | ||
- | < | + | See the video for details |
- | % Written | + | |
- | clear % Clear all variables | + | |
- | close all % Close all windows | + | |
- | + | ||
- | N = 20; % How many Fourier modes to include? | + | |
- | + | ||
- | % Define an in-line function that takes in three inputs: | + | |
- | % Input 1: n value [scalar] | + | |
- | % Input 2: x value [vector] | + | |
- | % Input 3: t value [scalar] | + | |
- | R = @(n, t, x) -2/ | + | |
- | + | ||
- | % Create a mesh of points between two limits | + | |
- | x0 = pi; | + | |
- | x = linspace(0, x0, 1000); | + | |
- | + | ||
- | % Create a mesh of points in time | + | |
- | t = linspace(0, 5, 200); | + | |
- | + | ||
- | figure(1); | + | |
- | plot([0, pi], [1, 1], ' | + | |
- | ylim([-0.2, | + | |
- | xlim([0, x0]); % Set the x limits | + | |
- | xlabel('x'); ylabel(' | + | |
- | hold on | + | |
- | for j = 1: | + | |
- | tj = t(j); | + | |
- | + | ||
- | u = 0; | + | |
- | for n = 1:N | + | |
- | u = u + R(n, tj, x); | + | |
- | end | + | |
- | + | ||
- | % Plotting commands | + | |
- | if j == 1 | + | |
- | p = plot(x, u, ' | + | |
- | else | + | |
- | set(p, ' | + | |
- | end | + | |
- | drawnow | + | |
- | title(['t = ', num2str(tj)]); | + | |
- | pause(0.1); | + | |
- | + | ||
- | if j == 1 | + | |
- | pause | + | |
- | end | + | |
- | end | + | |
- | </ | + |