MATLAB: Index exceeds matrix dimensions. error. The code is pasted below. please help me resolve this error. Thank you.

index exceeds matrix dimensions

% This is the script for Generalized Hardy Cross Analysis

Best Answer

Check lines:
A = [0 0 0 0 0; 0 -50.0 0 0 0] ;
A=0;
b = ((s(i,j)))*(A(i,j));
You have initialized A as 2x5 matrix, and then you made it to scalar 0. In line b = ((s(i,j)))*(A(i,j), you are trying to access it as matrix. Change considering those lines.
Same is the case with B also.