フィルターのクリア

Getting single answer for function with an array

1 回表示 (過去 30 日間)
Takura Nyatsuro
Takura Nyatsuro 2022 年 4 月 16 日
編集済み: Torsten 2022 年 4 月 16 日
Hi there,
Im trying to plot a graph of Drag against velocity. The velocity(V) in which is stored in an array from 20 to 100 in increments of 10. however when i calculate drag (D) the code only outputs a single output for drag instead of one output for each velocity.
Any help would be appreciated ,
Thank you
>> d=1.225;
>> S=50;
>> Cd=0.03;
>> K=0.04;
>> W=50;
>> V=[20:10:100];
>> D=((0.5)*d*(V.^2)*S*Cd+(K*W^2))/((0.5*d*(V.^2)*S))

回答 (1 件)

Torsten
Torsten 2022 年 4 月 16 日
D=(0.5*d*V.^2*S*Cd+K*W^2)./(0.5*d*V.^2*S)
instead of
D=((0.5)*d*(V.^2)*S*Cd+(K*W^2))/((0.5*d*(V.^2)*S))
  3 件のコメント
Voss
Voss 2022 年 4 月 16 日
編集済み: Voss 2022 年 4 月 16 日
./ is element-wise division:
[2 4 6 8]./[2 3 4 5] % = [2/2 4/3 6/4 8/5]
ans = 1×4
1.0000 1.3333 1.5000 1.6000
/ is matrix division:
[2 4 6 8]/[2 3 4 5]
ans = 1.4815
Torsten
Torsten 2022 年 4 月 16 日
編集済み: Torsten 2022 年 4 月 16 日
Since you already used elementwise multiplication for V, I didn't explain in detail what was the reason for the error. I thought it was only an oversight.

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

カテゴリ

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