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

4. As we have derived in class, given N subintervals set Dh, the reaction component is integrated as (L * r(z)un (2) dr, if i=1, S** *r(a)un(a)dx, if i = 2,---,N, 11* r(a)un(r) de if i = N +1. 1-1/2 To avoid symbolic calculations, approximate each of the above integrations by r(ci)un(Li)Ac; 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) % mat = sparse(diag(beta)); end 4. As we have derived in class, given N subintervals set Dh, the reaction component is integrated as (L * r(z)un (2) dr, if i=1, S** *r(a)un(a)dx, if i = 2,---,N, 11* r(a)un(r) de if i = N +1. 1-1/2 To avoid symbolic calculations, approximate each of the above integrations by r(ci)un(Li)Ac; 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) % mat = sparse(diag(beta)); end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
