Question: using MATLAB please!!! 4. As we have derived in class, given N subintervals set Dh, the reaction component is integrated as (L* * r (a)un

using MATLAB please!!!

using MATLAB please!!! 4. As we have derived in class, given N

4. As we have derived in class, given N subintervals set Dh, the reaction component is integrated as (L* * r (a)un () dz, if i=1, PI4+1/2 r(x)un(x) dx, if i = 2, ... ,N, 21-1/2 r(x)un(x) dx if i = N + 1. 1-1/2 To avoid symbolic calculations, approximate each of the above integrations by r(xi)un(xi)A.c; for i = 1, ... ,N +1. (4.3) The corresponding matrix has dimension (N+1) (N+1) and is diagonal: diag(B1, B2, ..., Bi,..., BN, Bn+1), (4.4) where Bi =r(xi)Axi, for i = 1, 2, ... ,N+1. (4.5) Construct a MATLAB function that returns the above diagonal matrix. A skeleton of this function is listed below, from which you can complete the rest of the operations. Make sure that you take the MATLAB's vectorized calculation/operations. You should be able to avoid for loop. function [mat] = assemble_reaction_matrix(mesh, bvpdata) % % Returns a sparse diagonal matrix resulting from approximation of % reaction % % fill the following array. beta; % values according to Eq. (4.5) % sparse(diag(beta)); end mat = 4. As we have derived in class, given N subintervals set Dh, the reaction component is integrated as (L* * r (a)un () dz, if i=1, PI4+1/2 r(x)un(x) dx, if i = 2, ... ,N, 21-1/2 r(x)un(x) dx if i = N + 1. 1-1/2 To avoid symbolic calculations, approximate each of the above integrations by r(xi)un(xi)A.c; for i = 1, ... ,N +1. (4.3) The corresponding matrix has dimension (N+1) (N+1) and is diagonal: diag(B1, B2, ..., Bi,..., BN, Bn+1), (4.4) where Bi =r(xi)Axi, for i = 1, 2, ... ,N+1. (4.5) Construct a MATLAB function that returns the above diagonal matrix. A skeleton of this function is listed below, from which you can complete the rest of the operations. Make sure that you take the MATLAB's vectorized calculation/operations. You should be able to avoid for loop. function [mat] = assemble_reaction_matrix(mesh, bvpdata) % % Returns a sparse diagonal matrix resulting from approximation of % reaction % % fill the following array. beta; % values according to Eq. (4.5) % sparse(diag(beta)); end mat =

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!