フィルターのクリア

Code error trying to find the max h

1 回表示 (過去 30 日間)
Briana Canet
Briana Canet 2023 年 9 月 20 日
回答済み: Walter Roberson 2023 年 9 月 20 日
Code not running fully. Continuous errors in code. I am trying to find the maximum h given f1, the other equations and other variable limitations.
% Variables
h = 10:0.01:16;
r = 14:0.01:22.13;
I = (pi*(r*2).^4)/(64);
P = ((4/3)*pi*(r.^3-(r-0.0127).^3)*7800*9.8)+((4/3)*pi*((r-0.0127).^3)*1000*9.8);
Pcr = (((pi)^2)*206*10^9*I)./(4*h.^2);
z = P <= Pcr/2;
f1 = -1*(h+2*r);
figure;
plot(r, h, 'o-');
xlabel('Radius');
ylabel('Height');
title('Problem 4i');
grid on;
  2 件のコメント
Matt J
Matt J 2023 年 9 月 20 日
編集済み: Matt J 2023 年 9 月 20 日
It would be clearer if the optimization problem was described using mathematical expressions rather than code. As posted above, we don't really know what you intend as an equation and what you intend as a code operation.
Briana Canet
Briana Canet 2023 年 9 月 20 日
Here is the mathematical expressions!

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

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 9 月 20 日
You have I divided by h where I is the size of r. But r and h are row vector of different lengths.
If each h has a corresponding r then make them the same length.
If r and h are varying independently and you want to find the best combination then make one a column vector instead of a row vector and switch to a 3d plot or contour plot instead of a line plot

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by