Write a (:,2) to a (:,6) matrix, depending on the value in (:,2) matrix.

Hi We are working on our bachelor as construction engineer, where we must build a static and dynamic beam analyzing system tool in MATLAB.
We want to define our system in the NE–matrix where each beam element is described in each row, where each node is numbered in column two and tree.
Each node from the NE-matrix (columns 2 and 3) must be written by 3 degrees of freedom (DOF), in a DOF-matrix. The matrix should be built in such a way, that the first node of the element is written in the first 3 columns, and the second node is written in the last 3 columns, a total of 6 columns.
This way we can describe each beam element in the rows, where the columns describes the degrees of freedom for the beam.
The node-DOF should be like this:
% DOF nr. 1 2 3 4 5 6 7 8 9 10 11 12
Node nr. 1 2 3 4
And so on…
The NE-matrix can be very big, so we want a system that can generate itself. The 3 DOF for each number must be “bounded”, because it can be a truss system, where another beam element is defined by an already used node.
The NE-Matrix simplified:
Node 1 Node 2
Beam element 1 1 2
Beam element 2 2 3
Beam element 3 2 4
Beam element 4 3 5
%
%To the DOF-matrix:
%
| *Node 1* | *Node 2* |
Dof 1 Dof 2 Dof 3 Dof 1 Dof 2 Dof 3
Beam 1 1 2 3 4 5 6
Beam 2 4 5 6 7 8 9
Beam 3 4 5 6 10 11 12
Beam 4 7 8 9 13 14 15
end
Do you know how to write it in MATLAB?
Tanks. Per

4 Comments

Is there any relation between the value of NE and DOF?
I don't follow -- as you've described it, it doesn't seem that DOF is really dependent at all upon NE but are instead simply linear sequences?
Try again on how NE(1,2) gets from the '1' in the location to '1:3' and even more particularly w/ NE(2,2). The numeric values you've given seem to be independent of the values in NE; if so it looks like it's simply a tridiagonal construct.
Well, I'm a NE, not structural, and maybe I'm dense but how does
The node-DOF should be like this:
% DOF nr. 1 2 3 4 5 6 7 8 9 10 11 12
Node nr. 1 2 3 4
translate to
%To the DOF-matrix:
%
| *Node 1* | *Node 2* |
Dof 1 Dof 2 Dof 3 Dof 1 Dof 2 Dof 3
Beam 1 1 2 3 4 5 6
Maybe if you were to use something other than sequential numbers the pattern could be discerned, but I don't yet see it from the description/example so far, sorry...
Thank you for trying. I can give you an example so you hopefully better understand the system. If we have a structure as shown in the picture here below:
Then we want to describe the system with the 3 degrees of freedom for each node. The 3 degrees of freedom describe each nodes abillity to move horizontal, vertically and rotational, for each beam element. as shown in the picture below:
Then we want to write the systems setup in a matrix manually (their coordinates are in another matrix, and are not significant in this matter). This is done in the NE-matrix as described before, Based on picture 1:
if true
% Beam element Node1 Node2 Material properties
NE = [ 1 1 2 1
2 2 3 1
3 2 4 1];
end
From this matrix it should generate a new matrix called DOF-matrix, which describes each beam elements DOF, by the NE-matrix. so you better understand the matrix i want, i numbered each DOF for the system as below:
Where i should generate this matrix:
if true
DOF = [ 1 2 3 4 5 6 % Beam element 1
4 5 6 7 8 9 % Beam element 2
4 5 6 10 11 12]; % Beam element 3
end
Where the first 3 columns refer to the first node 3DOF, and the last 3 columns refer to the last node 3DOF, see figure 2.

Sign in to comment.

 Accepted Answer

dofn = reshape(1:15,3,[])';
NE = [1 2
2 3
2 4
3 5];
dofc = num2cell(dofn,2);
DOF = cell2mat(dofc(NE));

1 Comment

Thank you very much. We rewrote it so it gererated the size automaticly.
if true
dofn = reshape(1:(max(NE(:,2))*3),3,[])';
%
dofc = num2cell(dofn,2);
DOF = cell2mat(dofc(NE(:,1:2)));
end
Then you can build a DOF matrix only dependent on the NE-matrix, and NE-matrix can have any size and setup.

Sign in to comment.

More Answers (0)

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Tags

Asked:

Per
on 2 May 2014

Commented:

Per
on 5 May 2014

Community Treasure Hunt

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

Start Hunting!