index exceeds matrix dimension

3 views (last 30 days)
whenever I create this function in editor
function r = Ymaxfinal(p,q)
r = ((-1000*p*q)/(27*(30*10^6)*0.163*(p+q)))*(p+(2*q))*((3*p(p+(2*q)))^0.5);
end
but when I call it in command window like Ymaxfinal(9,8)
it gives the error of Index exceeds matrix dimensions. plz help me
  1 Comment
Martin Olafsen
Martin Olafsen on 27 Sep 2017
You're missing a multiplication ("*").
r = ((-1000*p*q)/(27*(30*10^6)*0.163*(p+q)))*(p+(2*q))*((3* --->p<---(p+(2*q)))^0.5);
Use this: r = ((-1000*p*q)/(27*(30*10^6)*0.163*(p+q)))*(p+(2*q))*((3*p*(p+(2*q)))^0.5);
Regards

Sign in to comment.

Accepted Answer

KSSV
KSSV on 27 Sep 2017
Change this line:
r = ((-1000*p*q)/(27*(30*10^6)*0.163*(p+q)))*(p+(2*q))*((3*p(p+(2*q)))^0.5);
to
r = ((-1000*p*q)/(27*(30*10^6)*0.163*(p+q)))*(p+(2*q))*((3*p*(p+(2*q)))^0.5);
  2 Comments
Haseeb Ahmed Janjua
Haseeb Ahmed Janjua on 27 Sep 2017
thanks it works
god bless you
Haseeb Ahmed Janjua
Haseeb Ahmed Janjua on 27 Sep 2017
please check your gmail email id. I need help in Some patterns
will be grateful on your feedback

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!