필터 지우기
필터 지우기

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 CenterFile Exchange에서 Direct Search에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by