create n k matrix in matlab

i need to make n stiffness matrix...
k1=E1*A1/L1* [1 -1; -1 1];
K2=E2*A2/L2* [1 -1; -1 1];
K3...
K4...
..
.
.
KN=EN*A2/LN[1 -1; -1 1]
I TRIED THIS:
for i=1:1:NE
K(i)=(E(i)*A(i)/L(i)) .* [1 -1; -1 1]
end
where i have defined matrix E A and L but i am not getting it. help me please!

回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 9 月 15 日

0 投票

2 件のコメント

SAKSHI SINHA
SAKSHI SINHA 2015 年 9 月 15 日
thank you sir, but could u please elaborate a little?
Walter Roberson
Walter Roberson 2015 年 9 月 15 日
for i=1:1:NE
K{i}=(E{i}*A{i}/L{i}) .* [1 -1; -1 1];
end
Are you certain, by the way, that you want matrix division (E{i}*A{i}) * inv(L{i}) ? If you want element-by-element division use ./ instead of /
for i=1:1:NE
K{i}=(E{i}*A{i}./L{i}) .* [1 -1; -1 1];
end

サインインしてコメントする。

Thorsten
Thorsten 2015 年 9 月 15 日
編集済み: Thorsten 2015 年 9 月 15 日

0 投票

If E, A, L are matrices and the ith stiffness matrix is just the scalar s = E(i)*A(i)/L(i)) multiplied with matrix [1 -1; -1 1], you can generate your N stiffness matrices as
S = E.*A./L;
T = [1 -1; -1 1];
K = reshape(T(:)*S(:)', 2, 2, numel(S));
with the ith stiffness matrix given by
Ki = K(:,:,i);

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2015 年 9 月 15 日

編集済み:

2015 年 9 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by