You are on page 1of 3

%% triangle area, stiffness matrix

% clear variables; close all; clc;


% syms h
%
% % x = [5*h 6*h 5*h];
% % y = [5*h 5*h 6*h];
%
% x = [5*h 4*h 5*h];
% y = [5*h 5*h 4*h];
%
% a = sym(zeros(1,3));
% b = sym(zeros(1,3));
% c = sym(zeros(1,3));
% for n=1:3
% i=n+1;
% j=n+2;
%
% if(i>3)
% i=i-3;
% end
%
% if(j>3)
% j=j-3;
% end
%
% a(n) = x(i)*y(j)-x(j)*y(i);
% b(n) = y(i)-y(j);
% c(n) = x(j)-x(i);
% end
%
% syms x y
% N = sym(zeros(3,1));
% for n=1:3
% N(n)=a(n) + b(n)*x + c(n)*y;
% end
%
% Ae = 1/2*h^2;
% A = sym(zeros(3,3));
% for n=1:3
% for k=1:3
% A(n,k)=b(n)*b(k) + c(n)*c(k);
% end
% end
% A = 1/(4*Ae)*A;

%% --------- numeric
% clear variables; close all; clc;
% syms h
%
% % x = [0 6 0];
% % y = [-1 -1 1];
% x = [6 0 6];
% y = [1 1 -1];
%
% a = zeros(1,3);
% b = zeros(1,3);
% c = zeros(1,3);
% for n=1:3
% i=n+1;
% j=n+2;
%
% if(i>3)
% i=i-3;
% end
%
% if(j>3)
% j=j-3;
% end
%
% a(n) = x(i)*y(j)-x(j)*y(i);
% b(n) = y(i)-y(j);
% c(n) = x(j)-x(i);
% end
%
% Ae = 6*2/2;
%
% syms x y
% N = sym(zeros(3,1));
% for n=1:3
% N(n)=a(n) + b(n)*x + c(n)*y;
% N(n)=N(n)/(2*Ae);
% end
%
%
% A = zeros(3,3);
% for n=1:3
% for k=1:3
% A(n,k)=b(n)*b(k) + c(n)*c(k);
% end
% end
% A = 1/(4*Ae)*A;

%% ------ coefficient by 3 point


clc;
syms h
syms x y
% xy = [h h ; h 0 ; 2*h h];
% xy = [h h ; h 2*h ; 2*h h];
% xy = [h h ; h 0 ; 2*h h];
xy = [h h ; h 2*h ; 2*h h];
XY = [ones(3,1) xy];
b = [1 0 0]';
coeff1 = XY\b;
N1 = coeff1(1) + coeff1(2)*x + coeff1(3)*y

% xy = [h h ; h 0 ; 2*h h];
% xy = [h h ; h 2*h ; 2*h h];
% xy = [h h ; 2*h 0 ; 2*h h];
xy = [h h ; 2*h 2*h ; 2*h h];
XY = [ones(3,1) xy];
b = [1 0 0]';
coeff2 = XY\b;
N2 = coeff2(1) + coeff2(2)*x + coeff2(3)*y

% dive = coeff1(2)*coeff2(2) + coeff1(3)*coeff2(3)

You might also like