Why the "It follows the END that terminates the definition of the function "torusVolArea" " happens?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Juan Camilo Chaparro Gualdron
el 1 de Mzo. de 2021
Respondida: Rashed Mohammed
el 5 de Mzo. de 2021
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 comentario
KALYAN ACHARJYA
el 1 de Mzo. de 2021
There is no syntax error, but the code can be improved. problem?
Respuestas (1)
Rashed Mohammed
el 5 de Mzo. de 2021
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
0 comentarios
Ver también
Categorías
Más información sobre Animation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!