How read Matrix Market data into MATLAB?
이전 댓글 표시
Hello. I'd like to read matrix data from the following link: https://morwiki.mpi-magdeburg.mpg.de/morwiki/index.php/Linear_1D_Beam
The link tells me that it is in Matrix Market format, but I am unsure how to extract the M, E, K, B, and C matrices from the attached .m file. Could someone help me extract the data? I'd like to have access to the M, E, K, B, and C matrices the correspond to the following equation:

Here is what the .m file, LF10.m, looks like. There are 18 rows. There is also a .b, .c, .e, and .k file:

- Thank you
답변 (2개)
jonas-schulze
2022년 7월 12일
편집: jonas-schulze
2022년 7월 12일
load LF10.m
M = spconvert(LF10(2:end,:))
load LF10.m
m = LF10(1, 1)
n = LF10(1, 2)
i = LF10(2:end, 1)
j = LF10(2:end, 2)
v = LF10(2:end, 3)
M = sparse(i, j, v, m, n)
If the underlying matrix is symmetric, the market file will only contain half the matrix. In this case it's the lower triangular part, but I don't know whether it always is.
D = diag(diag(M))
L = tril(M, -1)
M = L + D + L'
Do you mean like this:
%%MatrixMarket matrix coordinate real symmetric
% System: M x_dotdot + E x_dot + K x = B u
% y = C x
%
% Steel beam, 5 nodes
% Properties: Length: 0.1 m, Density: 8000 kg/m^3, Diameter: 1 mm,
% Modulus of elasticity: 2.0e11 Pa, Poisson ratio: 0.29,
% Contr.of M to damping: 1e2, Contr. of K to damping: 1e-2.
% The output node is the node in the middle.
%
Mx = [18 18 50
1 1 8.2666855418381347E-11
2 1 2.3970604543209878E-08
2 2 5.1946160853333332E-05
3 1 -6.1709237860082308E-11
3 3 1.6533371083676269E-10
4 2 8.9335862399999995E-06
4 3 2.3970604543209878E-08
4 4 5.1946160853333332E-05
5 2 -2.3970604543209878E-08
5 3 -6.1709237860082308E-11
5 5 1.6533371083676269E-10
6 4 8.9335862399999995E-06
6 5 2.3970604543209878E-08
6 6 5.1946160853333332E-05
7 4 -2.3970604543209878E-08
7 5 -6.1709237860082308E-11
7 7 1.6533371083676269E-10
8 6 8.9335862399999995E-06
8 7 2.3970604543209878E-08
8 8 5.1946160853333332E-05
9 6 -2.3970604543209878E-08
9 7 -6.1709237860082308E-11
9 9 1.6533371083676269E-10
10 8 8.9335862399999995E-06
10 9 2.3970604543209878E-08
10 10 5.1946160853333332E-05
11 8 -2.3970604543209878E-08
11 9 -6.1709237860082308E-11
11 11 1.6533371083676269E-10
12 10 8.9335862399999995E-06
12 11 2.3970604543209878E-08
12 12 5.1946160853333332E-05
13 10 -2.3970604543209878E-08
13 11 -6.1709237860082308E-11
13 13 1.6533371083676269E-10
14 12 8.9335862399999995E-06
14 13 2.3970604543209878E-08
14 14 5.1946160853333332E-05
15 12 -2.3970604543209878E-08
15 13 -6.1709237860082308E-11
15 15 1.6533371083676269E-10
16 14 8.9335862399999995E-06
16 15 2.3970604543209878E-08
16 16 5.1946160853333332E-05
17 14 -2.3970604543209878E-08
17 15 -6.1709237860082308E-11
17 17 1.6533371083676269E-10
18 16 -2.3970604543209878E-08
18 17 -6.1709237860082308E-11
18 18 8.2666855418381347E-11];
M = zeros(18,18);
for r = 2:51
M(Mx(r,1), Mx(r,2)) = Mx(r,3);
end
disp(M)
댓글 수: 5
Justin Burzachiello
2021년 7월 15일
Alan Stevens
2021년 7월 15일
I assume the data for the other matrices is in the other files. I only looked at LF10.m. There are other files in the zip file.
Justin Burzachiello
2021년 7월 16일
Justin Burzachiello
2021년 7월 16일
Alan Stevens
2021년 7월 16일
Yes, that's the same matrix I regenerated from your file (the numbers are just displayed slightly differently).
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
