How to add "weight" to a 3D matrix

1 回表示 (過去 30 日間)
Jack Holland
Jack Holland 2018 年 3 月 27 日
回答済み: Rik 2018 年 3 月 27 日
Not sure of the terminology, but here is some context to hopefully explain it easier: I'm trying to create a function that is finding the optimum dimensions for an "I" beam. This "I" beam has 4 dimensions. a,b,c and h, where h is set and a,b and c can vary as shown in the code below. With h being the height, c the width and a,b being the height and width of one of the "cutout" sections. I picked 10 instances of a,b and c using linspace, and as a,b and c can vary independently I made a 10x10x10 matrix to express each possible outcome. However, I want this matrix (Area) to equal the area of the "I" beam which is given by the equation (Area=ch-2ba).
h = 30;
c = linspace(30,60,10);
b = linspace(1,h-2,10);
a = linspace(1,14,10);
A=[c.*b'];
area = zeros(10,10,10);
for k=1:10
area(:,:,k)=a(k);
end
Area=area.*A;
Is there a way to each of the 1x10 matrics in order to represent the area equation in the 10x10x10 matrix??Is there a way to each of the 1x10 matrics in order to represent the area equation in the 10x10x10 matrix??

採用された回答

Rik
Rik 2018 年 3 月 27 日
If you simply want to calculate Area=c*h-2*b*a for every combination of a, b, and c, the code below does that. If that is not what you mean, please explain what your code is not doing, and what the intended output is.
h = 30;
c = linspace(30,60,10);
b = linspace(1,h-2,10);
a = linspace(1,14,10);
[A,B,C]=meshgrid(a,b,c);
Area=C.*h-2*B.*A;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by