Why the "It follows the END that terminates the definition of the function "torusVolArea" " happens?

1 次查看(过去 30 天)
function [V, A] = torusVolArea (a, b)
% Calculating Volume
V = (1/4) * (pi * pi) * (a+b) * ((b-a) * (b-a));
% Calculate area
A = (pi*pi) * ((b*b) - (a*a));
end
% Vector for volume
vol = [];
% Vector for area
ar = [];
% Iterate a
for a = 0.25:4
% Calculate volume and area
[V A] = torusVolArea(a, a+2);
% Store volume in vector
vol = [vol V];
% Store area in vector
ar = [ar A];
end

回答(1 个)

Rashed Mohammed
Rashed Mohammed 2021-3-5
Hi Juan
For the function torusVolArea and the script to be present in the same file, the function body needs to be at the end of the script. By rearranging the code, you can resolve the error you are facing.
Hope this helps

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by