What is wrong with my code
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
N = 16;
E = 200e9; % Young Modulus (Pa)
b = 0.1; % Top width (m^2)
a = 0.025; % Bottom width (m^2)
L = 1.0; % Length (m)
rho = 77e3; % Force density (N/m^3)
Le = L./N;
ff = 0;
for i = 1:N
w(i)=(((i-0.5).*Le)*((b-a)./L))+a; %Calculates avg width (m)
A(i)=w(i).^2; %Calculates element area (m^2)
k(i) = A(i)*E/Le; %Local Stiffness Matrix constact
f(i) = ff*A(i)*le*rho/2; %Local Force Matrix constant
end
KG = zeros(N+1,N+1)
FG = zeros(N+1,N+1)
for ii = 1:N
KG(ii:ii+1,ii:ii+1)=KG(ii:ii+1)+k(i);
FG(ii:ii+1,ii:ii+1)=FG(ii:ii+1)+f(i);
end
Displacement = inv(KG)*FG;
plot(N,Displacement,'b');
hold on
plot(N,Displacement,'*','color','r')
ylabel('end deflection in mm');
xlabel('no of element')
5 Kommentare
Antworten (1)
Dinesh Yadav
am 23 Jul. 2020
Change to the following code
len = length(N) %N is 1x100 you want i to go from 1 to 100 therefore change to length(N) instean of N
for i = 1:len
w(i)=(((i-0.5)*Le(i))*((b-a)/L))+a; % Le is also 1x100 you want to take one elsment at a time use Le(i)
A(i)=w(i).^2; %
k(i) = (A(i)*E/Le(i));%*[1 -1;-1 1]; %
f(i) = (ff*A(i)*Le(i)*rho/2);%*[1;1]; %
end
KG = zeros(len+1,len+1);
FG = zeros(len+1,len+1);
for i = 1:len
0 Kommentare
Siehe auch
Kategorien
Mehr zu Spectral Measurements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!