필터 지우기
필터 지우기

whats wrong with this code?

조회 수: 1 (최근 30일)
Nathan
Nathan 2024년 4월 12일
댓글: Star Strider 2024년 4월 12일
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일
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일
i copied your code and it worked some seems identical but it worked
Star Strider
Star Strider 2024년 4월 12일
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 CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by