Question

In: Computer Science

Give me a working code in MATLAB for Crout Decomposition. The code must work totally fine...

Give me a working code in MATLAB for Crout Decomposition. The code must work totally fine and must break into 2 matrix L and U

It must be in MATLAB

The code used must use continue statement. If no continue statement is there in code it will be downvoted.

Answer only if you know or else i will dislike badly

Solutions

Expert Solution

MATLAB CODE which uses Crout's decompositon technique and also solves the system AX=B

clc;clear all
format long
a=[1 2 3;3 4 5;1 0 1];
b=[1;1;3];
[L,U]=CroutDecom(a);
y=ForwardSub(L,b);
x=BackwardSub(U,y)
function [L,U]=CroutDecom(A)
[r c]=size(A);
for(i=1:r)
U(i,i)=1;
L(i,1)=A(i,1);
if(i==1)
continue
end
U(1,i)=A(1,i)/(L(1,1));
end
for(i=2:r)
for(j=2:c)
L(i,j)=A(i,j)-L(i,1:j-1)*U(1:j-1,j);
if(j>=i+1)
U(i,j)=(A(i,j)-L(i,1:i-1)*U(1:i-1,j))./L(i,i);
end
end
end
end
function y=ForwardSub(a,b)
n=length(b);
y(1,1)=b(1)/a(1,1);
for i=2:n
y(i,1)=(b(i)-a(i,1:i-1)*y(1:i-1,1))./a(i,i);
end
end
function y=BackwardSub(a,b)
n=length(b);
y(n,1)=b(n)/a(n,n);
for i=n-1:-1:1
y(i,1)=(b(i)-a(i,i+1:n)*y(i+1:n,1))./a(i,i);
end
end
  


Related Solutions

Give me a MATLAB code which integrates any function using Romberg integration The code must work...
Give me a MATLAB code which integrates any function using Romberg integration The code must work fine or else I will down vote the answer badly Dont post if you dont know
Give me a working MATLAB code for the Golden section search method . It should be...
Give me a working MATLAB code for the Golden section search method . It should be working Dont answer if you do not know, the code must work for the golden section method
I need a working MATLAB CODE for the Gram Schimdt process Please give the code fast...
I need a working MATLAB CODE for the Gram Schimdt process Please give the code fast Its urgent The code must run on any matrix given It should be a generic code Dont answer any wrong code or else i will badly dislike
Implement the steffenson method in matlab. The code must be in MATLAB DOnt answer if you...
Implement the steffenson method in matlab. The code must be in MATLAB DOnt answer if you cannot give correct MATLAB
The following code must be written using matlab How to loop through a vector in matlab...
The following code must be written using matlab How to loop through a vector in matlab and assigning a value to every 4th entry. The vector could be of any length. Thanks
please let me know reference of this MATLAB code. please explain this code line by line....
please let me know reference of this MATLAB code. please explain this code line by line. . . N=256; %% sampling number n=linspace(0,1,N); fs=1/(n(2)-n(1)); x=5*(sin((2*pi*10*n))); %% create signal N=length(x); f=[-fs/2:fs/N:fs/2-fs/N]; subplot(211) plot(f,fftshift(abs(fft(x)))); title('|G(f)|');grid; xlabel('frequency'); ylabel('|G(f)|'); %Zero padding xx=[zeros(1,128) x zeros(1,128)]; N=length(xx); f=[-fs/2:fs/N:fs/2-fs/N]; subplot(212) plot(f,fftshift(abs(fft(xx)))); title('|Gz(f)|');grid; xlabel('frequency'); ylabel('|Gz(f)|');
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals for position 1, position 2, position3 and position 4 of the array. After these first 4 positions are drawn. The whole thing should start over where position5 drawn from same interval as positions 1, position6 drawn from same interval as...
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals in chunks of 4 , that is chunk1-chunk2-chunk3-chunk4 The parameters for specifying the lintervals by which the random numbers should be drawn should be able to change and be hardcoded in the script, however, be hardcoded in the script.
For a catapult project I must make a MATLAB code that should make use of the...
For a catapult project I must make a MATLAB code that should make use of the projectile motion equations so for a given input range R (horizontal distance from the catapult to the target), the code outputs the necessary velocity and firing angle of the catapult. What is the code for this? I am lost.
For a catapult project I must make a MATLAB code that should make use of the...
For a catapult project I must make a MATLAB code that should make use of the projectile motion equations so for a given input range R (horizontal distance from the catapult to the target), the code outputs the necessary velocity and firing angle of the catapult. I must be able to input ranges: 7ft, 8ft and 9ft and the output of the code should give me the possible velocities and theta of the catapult.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT