Setting up a matrix from input file?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a file that has 7 nodes and 8 elements that I am retrieving data from.
I am currently trying to set-up a stiffness matrix but I am struggling with coming up with the correct code to build my matrix.
Below is the format from my .inp file. The first row is the number of the element and the other two columns are were the nodes are connected at. So in other words element 1 is connected at nodes 1 and 7.
if true
% code
end
1 1 7
2 3 5
3 7 6
4 4 6
5 4 1
6 4 2
7 5 7
8 2 5
I got it to read each column by calling each column N1, N2, N3 but then when I do A=[N1; N2; N3]
it gives me:
if true
% code
end
A =
1
2
3
4
5
6
7
8
1
3
7
4
4
4
5
2
7
5
6
6
1
2
7
5
Please Help
Thank you!
0 件のコメント
採用された回答
Image Analyst
2014 年 10 月 5 日
Using a semicolon puts the matrices one atop the other (vertical concatenation). Using a comma puts them side by side (horizontal concatenation). Try this
A=[N1, N2, N3]
Or just read it into A directly with dlmread() or readtable().
A = dlmread(filename, ' ');
その他の回答 (1 件)
参考
カテゴリ
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!