How to input this finite element analysis matrix in matlab?

hi there, I have no idea how to input this matrix in Matlab. This matrix is derived from a finite element analysis problem. It is a ne*ne matrix where ne represents the number of element. A is a vector, it is a function of x, and x is a vector of ne elements.
thanks in advance!

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 4 Jun. 2017
Bearbeitet: Andrei Bobrov am 5 Jun. 2017
example:
create of A vector
ne = 7;
L = 0.5;
dx = L/ne;
x = (dx:dx:L)';
A = pi* (0.03-0.017455*L+0.017455*x).^2;
one way
out = full(spdiags([[-A(2:end);0],conv2(A,[1;1],'same'),[0;-A(2:end)]],-1:1,ne,ne));
other way
out = zeros(ne);
out(1:ne+1:end) = conv2(A,[1;1],'same');
out(2:ne+1:end-1) = -A(2:end);
out(ne+1:ne+1:end) = -A(2:end);
more
out = full(gallery('tridiag',-A(2:end),conv2(A,[1;1],'same'),-A(2:end)));

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 4 Jun. 2017

Kommentiert:

am 5 Jun. 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by