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!