ive written a code and the numbers on the x and y axis show up but im not getting any actual plots.
w = input('Enter weight "W" of aircraft value(kg)');
c_d0 = input('Enter profile drag coefficient "C_d0" of aircraft value');
s = input('Enter wing span "S" of aircraft value(m)');
p_0 = input('Enter initial power at sea level "P_0" of aircraft engine value(W)');
k = input('Enter induced drag coefficient "K" of aircraft value');
rho_0 = 1.225;
h=0:0.1:20;
for i=1:length(h)
sigma(i)=20-h(i)/20+h(i);
a=c_d0*0.5*rho_0*s;
b=-p_0;
c=k*w^2/0.5*rho_0*sigma(i).^2*s;
y=[a 0 0 b c];
r=roots(y);
end
plot(r(3),h,r(4),h)

댓글 수: 2

KSSV
KSSV 2020년 6월 4일
h happens to be a vector, and r(3) , r(4) are scalars......you cannot plot like that.
Adeola Badejo
Adeola Badejo 2020년 6월 4일
i see so how would you suggest i fix it?

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

답변 (1개)

KSSV
KSSV 2020년 6월 4일

0 개 추천

w = input('Enter weight "W" of aircraft value(kg)');
c_d0 = input('Enter profile drag coefficient "C_d0" of aircraft value');
s = input('Enter wing span "S" of aircraft value(m)');
p_0 = input('Enter initial power at sea level "P_0" of aircraft engine value(W)');
k = input('Enter induced drag coefficient "K" of aircraft value');
rho_0 = 1.225;
h=0:0.1:20;
r3 = zeros(size(h)) ;
r4 = zeros(size(h)) ;
for i=1:length(h)
sigma(i)=20-h(i)/20+h(i);
a=c_d0*0.5*rho_0*s;
b=-p_0;
c=k*w^2/0.5*rho_0*sigma(i).^2*s;
y=[a 0 0 b c];
r=roots(y);
r3(i) = y(3) ;
r4(i) = y(4) ;
end
plot(r3,h,r4,h)

댓글 수: 4

Adeola Badejo
Adeola Badejo 2020년 6월 4일
it plots now thank you i just dont think it plots the right answer
KSSV
KSSV 2020년 6월 4일
The asked question purpose is solved. The right answer depends on what the problem is.
Adeola Badejo
Adeola Badejo 2020년 6월 4일
the problem is to plot a graph of the minimum and maximum roots against h whichould give me a parabola but instead gives me a straight line so i must have gone wrong somewhere
KSSV
KSSV 2020년 6월 4일
You can get min and max using:
r3(i) = min(y) ;
r4(i) = max(y) ;
You need to rethink on your code.

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

카테고리

도움말 센터 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기

태그

질문:

2020년 6월 4일

댓글:

2020년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by