Plot not generating graph

2 ビュー (過去 30 日間)
azaandria
azaandria 2021 年 3 月 3 日
コメント済み: Star Strider 2021 年 3 月 3 日
I have the below two functions and script below. I am trying to plot (a,ratio), but my graph is coming up blank?
Could someone please take a look at what Im doing wrong?
function [CL,CD] = CL_and_CD(a)
%CL_and_CD accepts alpha input,returns two outputs CL/CD
% Calculates the lift and drag co-efficients "CL" & "CD"
CL = (4.47*(10^-5*(a.^3))+(1.15*(10^-3)*(a.^2))+(6.66*(10^-2).*a)+1.02*(10^-1));
CD = (5.75*(10^-6*(a.^3))+5.09*(10^-4*(a.^2))+1.81*(10^-4.*a)+1.25*(10^-2));
end
function [ratio] = L_to_D(CL,CD)
%L_to_D accepts two inputs and returns one output
%Accepts inputs for CL & CD, and produces the Lift to Drag ratio.
ratio= CL/CD;
end
%Input
a=(-2:0.1:22);
%Call to function CL_and_CD
[CL,CD]=CL_and_CD(a);
%Call to function Ratio
[ratio]= L_to_D(CL,CD);
%Plot
plot(a,ratio);
xlabel('Angle of attack (\alpha)');
ylabel('Lift to Drag Ratio');
title('Lift to Drag Ratio by Angle of attack (\alpha)');

採用された回答

Star Strider
Star Strider 2021 年 3 月 3 日
Do element-wise division in ‘L_to_D’:
ratio= CL./CD;
Then it works and the plotted curve appears!
  2 件のコメント
azaandria
azaandria 2021 年 3 月 3 日
Thank you so much. I was going cross eyed trying to figure it out
Star Strider
Star Strider 2021 年 3 月 3 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by