MATLAB: How to solve the error “Index in position 2 exceeds array bounds.”

#matlabcode #dissertation

Hi, I'm running a code and I keep getting this error
'Index in position 2 exceeds array bounds'
How do i fix it please, The corona virus has really restricted my movement

Best Answer

It turns out that the error is caused by wrong field names in the function truss2D_readdata. Some field names in the text file are a bit different as compared to the function. Change the line
matprop.yield = fscanf(fid, '\nYIELD_STRESS = %f', 1);
to
matprop.yield = fscanf(fid, '\nYIELD STRESS = %f', 1);
and change the line
npload = fscanf(fid,'\nPOINT_LOADS = %d',1);
to
npload = fscanf(fid,'\nNODES_WITH_POINT_LOAD = %d',1);