Help a noob with syntax!
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2013년 4월 14일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!