Updating a zeroized matrix with provided row vectors

1 次查看(过去 30 天)
So I'm not sure if this can be done, but this is what I'm trying to do. I have a matrix (Force) that I've initialized to zero, it will always have three columns, but the rows will vary based on the nnd variable (determined by user input). Also based on user input is the Nodal Loads matrix, where Column 1 is the node number and column 2:4 are nodal loads. As you can see, there are nodes missing in the user input, meaning that if the user didn't input a value, then that nodal row remains zero. Is there a way to take the user input for Nodal_Loads and update the information into the Force matrix? My desired endstate is shown below. Thanks for the help.
Nodal_Loads = [2 0 -1000 0] %example 1
or
Nodal_Loads = [1 0 0 40; 3 -1000 0 40; 4 0 2000 40; 5 0 0 40; 8 1000 -2000 40; 9 0 0 40] %example 2
nnd = 9 %can be any number based on user input (I'll just say 9 for this example)
Force = zeros(nnd,3)
(Desired Endstate) %example 2
Force matrix now looks like:
Force = [0 0 40; 0 0 0; -1000 0 40; 0 2000 40; 0 0 40; 0 0 0; 0 0 0; 1000 -2000 40; 0 0 40]

采纳的回答

BobH
BobH 2020-3-10
Force(Nodal_Loads(:,1),:) = Nodal_Loads(:,2:4)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by