How can I loop into a matrix?
Show older comments
I have six values of E and v which are entries of Matrix s of the structure; s=[1/E -v/E 0; v/E 1/E 0; 0 0 2*(1+v)/E]
the six matrices of s formed are the entry into the matrix S; S=[s(1) s(2) s(3) s(4) s(5) s(6)]
How can I loop the values of E and v into the matrix s?
2 Comments
Image Analyst
on 7 Mar 2014
Are E and V row matrices or column matrices? What do you think the size of little should be? And what about big S? Can you give a numerical example?
saheed
on 7 Mar 2014
Accepted Answer
More Answers (1)
I think that you need to loop here, since Matlab do normally not implement any operations that you reuqests. I mean
[vector, 0; 0, vector]
gets the size 2 x length(vector)+1
try something like
s = [];
for k = 1:length(E)
s_temp= [1/E(k) -v(k)/E(k) 0; v(k)/E(k) 1/E(k) 0; 0 0 2*(1+v(k))/E(k)];
s = [s,s_temp];
end
I may have some syntax errors since the code is not tested, but I guess it should work. Of course you can also preallocate vectors and so as well to speed up the code, if that is necessary.
Good luck!
Categories
Find more on Loops and Conditional Statements 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!