필터 지우기
필터 지우기

why do i keep getting index exceeds matirx dimensions?

조회 수: 1 (최근 30일)
parsh
parsh 2012년 4월 1일
I just typed in simple codes for plotting a graph and i keep getting the same error why is that?
d=1:1:10
theta=pi/4;
Dc= d/2.*(1-cos(theta));
Q= (2.^(3/2).*Dc.^(5/2).*sqrt(g).*(theta-0.5.*sin(2.*theta)).^(3/2))/(8.*sqrt (sin(theta).*(1-cos(theta).^(5/2))))
subplot (2,1,2);
plot (d,Q)
title('17473981')
xlabel('diameter')
ylabel('flow rate')
grid on

채택된 답변

the cyclist
the cyclist 2012년 4월 1일
What is "g"? If I set g=1, your code works for me.
Might you have accidentally define your own variable named "cos", "sin", or "sqrt", so MATLAB thinks it is indexing a variable?
  댓글 수: 4
parsh
parsh 2012년 4월 1일
umm... it works. :) thank you so much
the cyclist
the cyclist 2012년 4월 1일
Glad it worked, but that drastic solution does not necessarily help you understand where you went wrong. My best guess is that maybe you accidentally defined a new variable (maybe "xlabel") and MATLAB was trying to access that instead of the built-in function.

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

추가 답변 (1개)

Rick Rosson
Rick Rosson 2012년 4월 1일
Please post the exact error message and indicate which line is triggering the error.
  댓글 수: 3
Image Analyst
Image Analyst 2012년 4월 1일
Funny - I get "Undefined function or variable 'g'."
parsh
parsh 2012년 4월 1일
yeah i forgot to put in the value of g, my mistake. thanks you

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by