필터 지우기
필터 지우기

Calculation of a column

조회 수: 4 (최근 30일)
Ke Yeun Yong
Ke Yeun Yong 2023년 9월 19일
댓글: Voss 2023년 9월 19일
Hi,
I have a column with 53 rows of different numbers. I only want to do formula calculation until the 45th row and the remaining 8 rows I want to make them the same value. All the results will be compile in the same column. May I know how that can be done?
With Altitude having the column (53 rows of number),
To = 288.15; % Temperature in ISA [K]
for i = 1:53
Ta (i) = To-0.0065*Altitude(i); % Temperature at altitude [K]
end
From above code, how do I make the calculation stop at 45th row and the remaining 8 rows will have the value of 216.65? and all new 53 rows of values will be under 1 column?
Thank you very much.

채택된 답변

Voss
Voss 2023년 9월 19일
To = 288.15; % Temperature in ISA [K]
% pre-allocate Ta to be the same size as Altitude (53x1), with all elements 216.65
Ta = 216.65*ones(size(Altitude));
% calculate the first 45 elements of Ta:
Ta(1:45) = To-0.0065*Altitude(1:45); % Temperature at altitude [K]
  댓글 수: 4
Ke Yeun Yong
Ke Yeun Yong 2023년 9월 19일
Hi,
CDO = 0.023; % Zero-lift drag coefficient
K = 0.044; % Lift-induced drag factor
MTOW = 79010; % Maximum take-off mass [kg]
W = MTOW*9.81; % Weight in N
A= Thrust_22K/W;
B = sqrt((A.^2)+(12*CDO*K));
Cl = (6*CDO)/(A+B)
Thrust_22K is a column with 53 rows and I am trying to calculate for Cl as above but the results on shows the first row result and the rest is zero. May I know what have i did wrong?
Thank you very much.
Voss
Voss 2023년 9월 19일
Use ./ for element-wise division.
Cl = (6*CDO)./(A+B);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by