フィルターのクリア

whats wrong with this code?

15 ビュー (過去 30 日間)
Nathan
Nathan 2024 年 4 月 12 日 2:22
コメント済み: Star Strider 2024 年 4 月 12 日 2:46
function [drag] = aero_drag(dens,v,A)
Fd = 0.5 .* dens .* (v.^2) .* A .* 0.55.*sign(v);
drag = Fd
File: areo_drag.m Line: 1 Column: 10
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.

回答 (1 件)

Star Strider
Star Strider 2024 年 4 月 12 日 2:30
It works here.
How are you calling your ‘aero_drag’ function?
dens = rand
dens = 0.3011
v = rand
v = 0.7408
A = randn(1,5)
A = 1x5
0.2096 -1.3985 0.6751 1.1753 -0.3353
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
drag = aero_drag(dens,v,A)
drag = 1x5
0.0095 -0.0635 0.0307 0.0534 -0.0152
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
function [drag] = aero_drag(dens,v,A)
Fd = 0.5 .* dens .* (v.^2) .* A .* 0.55.*sign(v);
drag = Fd;
end
.
  2 件のコメント
Nathan
Nathan 2024 年 4 月 12 日 2:36
i copied your code and it worked some seems identical but it worked
Star Strider
Star Strider 2024 年 4 月 12 日 2:46
Thank you!
It may simply have needed an end, or alternatively, needed to be put at the end of your script. (I’m not certain, because I don’t know where it was in your script, or how you called it.)

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

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by