How to use the Sum function in this instance

Hello, Ive been writing code for one of my modules and came across a formula that I dont understand how to put it in matlab, it is this equation below:
My problem is that I dont understand how to use the sum function in this instance

4 件のコメント

John D'Errico
John D'Errico 2023 年 2 月 8 日
Is x known? Is z known? Is Ar known? What are they? Are they variables, constants? Symbolic? What?
Is the sum taken as 5:1:85? I find it strange that the sum does not go all the way down to 0 or up to 90, since this is clearly an angle, represented in degrees.
It is easer to help you if you tell us enough to know what form are the variables in that expression.
Ahmed Alzaabi
Ahmed Alzaabi 2023 年 2 月 8 日
Ah Sorry about that Ill post those values:
%A symmetric Trim Calculator for Subsonic Flight Conditions
% Aircraft Flight Conditions (Make sure to check if unit change is needed
% for ft to meter and degrees to radians
Alt = 0; %Altitude (ft)
A_Mass = 0; %Aircraft Mass (kg)
cg_p = 0; % cg Position (%c)
Flight_path_angle = 0; % Flight Path angle in Degrees
G0 = 9.81; %Gravity Constant
%Air Density calculation - Valid for tropospwhere only up to 36,000ft
R = 287.05 % Gas Constant
L_R = -0.0065; %Lapse rate
Temp = 288.16 + (L_R * Alt); %Temperature
rho = 1.225 * ((Temp)/288.16)^(-((G0)/(L_R * R)+1))
sigma = rho/1.225 %Density ratio
%Setting up the Velocity Range for Computations
%Setting the counter i from 0 - 10
counter = 0:10
%Setting up the array to save result for wach itteration
results = zeros(1, length(counter));
%Loop Itteration
for i = 1:length(counter)
results(i) = 100 + (15*i); %Outputs the True airspeed range in Knots
end
V_TAS = results .*0.515;
Eq_airspeed = results .*sqrt(sigma);
%Aircraft Geometry Constant
%Wing Geometry
% Aircraft Geometry- Constants
S = 0; % Wing Area m^2
b = 0; % Wing Span
cw = 0; % Wing mean chord
sweep = 0; %Sweep 1/4cw
zw = 0; % Z coordinate of 1/4wc point above (-ve) or below (+ve) ox body axis (m)
alpha_wr = 0; % Wing Rigging
%Tailplane Geometry
St = 0; % Tailplane area
bt = 0; % Tailplane span
It = 0; % Tail arm, 1/4cw to 1/4ct
Zt = 0; % Z coordinate of 1/4wc point above (-ve) or below (+ve) ox body axis (m)
nt = 0; %Tail setting angle
Fd = 0; % Fuselage Diameter
%Engine Installation
zt = 0; %Thrust line z coorrdinate above (-ve) or below (+ve) ox body axis (m)
k = 0; %Engine thrust line angle relative to ox body axis (+nose up)
Wing-body aerodyanmics
a = 0; %Wing-body CL - alpha (per rad)
CL_max = 0; % Maximum Lift Coefficient
Cm_0 = 0; % Zero lift pitching moment
CD_0 = 0; % Zero lift drag coefficient
AOA_0 = 0; %Zero lift angle of attack
h_0 = 0; %Wing-body aero centre
%Tailplane aerodynamics
a1 = 0;% TailplaneCL-α (per rad)
a2 = 0;% ElevatorCL-η (per rad)
e0 = 0;%Zero lift downwash angle(deg)
%Wing and Tailplane Calculations
Ar = (b^2)/(S); % Aspect ratio
wing_semi = b/2 ; % Wing Semi Span
Tail_arm = It - cw *(cg_p - 0.25) ; % Tail arm, cg to 1/4ct
V_T = ((St *Tail_arm)/(S*cw)); % Tail Volume
Torsten
Torsten 2023 年 2 月 8 日
Are you sure you included the correct code ?
And you didn't tell us about x and z.
So far I can see that if a = 0 as in your code, d_eps_alpha will also be 0.
Ahmed Alzaabi
Ahmed Alzaabi 2023 年 2 月 8 日
I didn't put the values in yet that's why all of the variables are 0. All of the values are scalar meaning they will hold 1 value only, that's why initially I didn't put my code as I have all of the values of the variable shown in the equation above. I just need help setting that equation in terms of matlab code.

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

 採用された回答

Image Analyst
Image Analyst 2023 年 2 月 9 日

1 投票

Take it one term at a time, like
fi = 5 : 85;
term1 = 0.5 * cosd(fi) .^ 2
term2 = whatever
numerator = whatever
denominator = whatever
d = scalingFactor * sum(numerator ./ denominator);
I know you can do it. I have confidence in you.

その他の回答 (1 件)

Matt J
Matt J 2023 年 2 月 8 日
編集済み: Matt J 2023 年 2 月 8 日

0 投票

Assuming all your variables (x,z,Ar, etc...) are scalars, then,
fi=5:85;
q1=0.5*cosd(fi).^2;
q2=q1+z^2;
q3=sqrt(x^2+q2);
d=(a/pi^2/Ar)*sum( (q1./q3).*( (x+q3)./q2 +x./(x^2+z^2) ) ) * pi/180

2 件のコメント

Paul
Paul 2023 年 2 月 8 日
Missing "a" out front?
Matt J
Matt J 2023 年 2 月 8 日
Yep. Fixed it.

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

カテゴリ

ヘルプ センター および File ExchangeGuidance, Navigation, and Control (GNC) についてさらに検索

製品

リリース

R2021b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by