Help a noob with syntax!
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Okay I'm really new to Matlab and trying to code something for my assignment. Can someone please look at this code and tell me what all is wrong? I'm damn sure there is some syntax problem! The error I'm getting right now is:
Subscript indices must either be real
positive integers or logicals.
Error in RectangularSection (line 5)
D(i) = DeltaY*x;
CODE:
function [N]=RectangularSection(BaseWidth,Depth,RoughnessBase,RoughnessLeftFace,RoughnessRightFace,NoOfSections)
if NoOfSections > 0
DeltaY = Depth/NoOfSections;
for x=0:NoOfSections
D(i) = DeltaY*x;
N(i) = ((BaseWidth*RoughnessBase^(3/2)+DeltaY*x*RoughnessLeftFace^(3/2)+DeltaY*x*RoughnessRightFace^(3/2))/(BaseWidth + 2*x*DeltaY))^(2/3);
end
plot(N,D)
title('Roughness vs Depth');
xlabel('Depth');
ylabel('Roughness');
end
0 comentarios
Respuestas (1)
Walter Roberson
el 14 de Abr. de 2013
That is not a syntax error. You have not assigned a value to "i", so it has it's default value, and the default value for "i" (and for "j" as well) is sqrt(-1)
0 comentarios
Ver también
Categorías
Más información sobre Performance and Memory 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!