Help a noob with syntax!
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 14 Avr 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 commentaires
Voir également
Catégories
En savoir plus sur Performance and Memory dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!