whats wrong with this code?
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
Star Strider
2024년 4월 12일
It works here.
How are you calling your ‘aero_drag’ function?
dens = rand
v = rand
A = randn(1,5)
drag = aero_drag(dens,v,A)
function [drag] = aero_drag(dens,v,A)
Fd = 0.5 .* dens .* (v.^2) .* A .* 0.55.*sign(v);
drag = Fd;
end
.
댓글 수: 2
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 Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!