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?

采纳的回答

Matt J
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
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.
Rémi Durocher
Rémi Durocher 2020-4-25
That makes a lot more sense. Thanks for your help!

请先登录,再进行评论。

更多回答(0 个)

类别

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