Can you please help me check my code? It is outputting only the last value instead of all the values generated in for loop. Thank you.

1 次查看(过去 30 天)
a = 0.5;
b = 0.1;
E = 0.2;
v = 0.3;
Y= (E/(1-v^2));
ve = [1 v 0; v 1 0; 0 0 (1-v)/2];
uu = [-0.02 0.012 -1.23 0.2343 -0.124 1.111 0.214 0.453];
for i = 1:length(nu);
for j = 1:length(eta);
nu = -1:0.01:1;
eta = -1:0.01:1;
B(i,j) = [-(1-nu)/(4*a) 0 (1-nu)/(4*a) 0 (1+nu)/(4*a) 0 -(1+nu)/(4*a) 0;...
0 -(1-eta)/(4*b) 0 -(1+eta)/(4*b) 0 (1+eta)/(4*b) 0 (1-eta)/(4*b);...
-(1-eta)/(4*b) -(1-nu)/(4*a) -(1+eta)/(4*b) (1-nu)/(4*a) (1+eta)/(4*b) (1+nu)/(4*a) (1-eta)/(4*b) -(1+nu)/(4*a)];
e(i,j) = B(i,j)*uu';
sig(i,j) = Y.*ve*e(i,j); % calculate the sig for each of the count and store it in sigsig
end
end
sigsig = [sig(i,j)]; % store all the sig here, each sig as a row vector

回答(1 个)

Walter Roberson
Walter Roberson 2017-3-20
In the line
for i = 1:length(nu);
nu has not yet been defined.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by