フィルターのクリア

Updating a zeroized matrix with provided row vectors

1 回表示 (過去 30 日間)
Damon Schmidt
Damon Schmidt 2020 年 3 月 10 日
コメント済み: Damon Schmidt 2020 年 3 月 10 日
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)
  1 件のコメント
Damon Schmidt
Damon Schmidt 2020 年 3 月 10 日
That's perfect and very simple. Thanks, I'll make sure to take note of this for future use.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by