How to save each resultant matrix from a for loop
Show older comments
I want to pick each resultant value of K from the first loop and insert into the second loop one by one
clc
clear all
no_nodes = 5;
A = 8;
E = 1.9e6;
L = 36;
k = A*E/L;
th = [0,pi/4,pi/2,3/4*pi];
for i = 1:4
theta = th(i);
s = sin(theta);
c = cos(theta);
angle_mat =[c.^2 s*c -c.^2 -s*c;
s*c s.^2 -s*c -s.^2;
-c.^2 -s*c c.^2 s*c ;
-s*c s.^2 s*c s.^2 ];
K = k*angle_mat;
end
zero_mat = zeros(no_nodes*2);
for i = [1 3 5 7]
zero_mat(i:i+3,i:i+3)= K
zero_mat = zeros(no_nodes*2);
end
as it can be seen that at the moment it is only picking the last resultant matrix and putting it in the second loop
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Network Parameters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!