Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
me3255_group9/Coefficients.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
67 lines (60 sloc)
1.71 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ w1 ] = Coefficients( n,EIpa,L ) | |
%Coefficients calculates the values of the w matrix where the values | |
%represent the coefficients of each node in the computational domain. The | |
%coefficient matrix is of the form: Ax = b | |
%The problem is posed as a Ax = (lambda)x = 0 so this makes sense to write | |
%the matrix as a coefficient matrix | |
% Change in x for central difference formula for 6 segments, dx6 | |
dx = L/n; | |
% Precalculate denominator in central difference equation | |
dx4 = dx^4; | |
% Precalculate coefficients' constant (see derivation) | |
K = (EIpa)/dx4; % Central points coefficient | |
Kf = (EIpa)/(2*dx); % boundary points coefficients (i = 2, i = n) | |
% Preallocate w matrix | |
w1 = zeros(n+1,n+1); | |
% Generate coefficient matrix for computational domain | |
% Boundary nodes w(1) and w(n+1) should equal zero | |
for i = 1:n+1 | |
if i == 1 | |
w1(i,i) = 6*K; | |
w1(i,i+1) = -4*K; | |
w1(i,i+2) = K; | |
elseif i == 2 | |
w1(i,i-1) = -4*K; | |
w1(i,i) = 6*K; | |
w1(i,i+1) = -4*K; | |
w1(i,i+2) = K; | |
elseif i == n | |
w1(i,i-2) = K; | |
w1(i,i-1) = -4*K; | |
w1(i,i) = 6*K; | |
w1(i,i+1) = -4*K; | |
elseif i == n+1 | |
w1(i,i-2) = K; | |
w1(i,i-1) = -4*K; | |
w1(i,i) = 6*K; | |
else | |
w1(i,i-2) = K; | |
w1(i,i-1) = -4*K; | |
w1(i,i) = 6*K; | |
w1(i,i+1) = -4*K; | |
w1(i,i+2) = K; | |
end | |
end | |
%% Code Debug: NOT NECESSARY (CONFIRMED VIA EMAIL) | |
% w2 = w1; | |
% % If Boundary nodes are different: | |
% % Written using forward and backward difference equations | |
% % First Node | |
% i = 1; | |
% w2(i,i) = -3*Kf; | |
% w2(i,i+1) = 4*Kf; | |
% w2(i,i+2) = -Kf; | |
% % Last Node | |
% i = n+1; | |
% w2(i,i) = 3*Kf; | |
% w2(i,i-1) = -4*Kf; | |
% w2(i,i-2) = Kf; | |
% | |
end | |