Creating Multiple Arrays within a For Loop
2 次查看(过去 30 天)
显示 更早的评论
I'm wondering if there is a way the create multiple new arrays within a for loop.
I have the following equation that I'm trying to use.
The right hand side 3x1s are constant, but there are multiple values of z which then change 3x1 value on the left hand side.
Is there way that I could have z1 give LHS array 1, z2 give LHS array 2 and so within a for loop?
0 个评论
采纳的回答
Matt J
2020-4-25
编辑:Matt J
2020-4-25
You wouldn't do that with a loop. You would just use vector arithemtic,
eps0=rand(3,1); %fake RHS data
kappa=rand(3,1);
z=rand(1,20);
eps=eps0+kappa*z;
epsxx=eps(1,:);
epsyy=eps(2,:);
gammaxy=eps(3,:);
3 个评论
Matt J
2020-4-25
Let's rename things a bit,
strain=eps0+kappa*z; %formerly eps=eps0+kapp*z
Here, strain will be a 3xN matrix whose columns are each of the N strains. So you have all of your results in that one matrix.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!