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

조회 수: 1 (최근 30일)
Juan Camilo Chaparro Gualdron 2021년 3월 1일
답변: Rashed Mohammed 2021년 3월 5일
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이전 댓글 -1개 표시이전 댓글 -1개 숨기기
KALYAN ACHARJYA 2021년 3월 1일
There is no syntax error, but the code can be improved. problem?

댓글을 달려면 로그인하십시오.

### 답변 (1개)

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에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by