How to fix: Index exceeds the number of array elements (4).
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, im write a coding to estimate the specific volume v of steam for the pressure range 0.01 through 10MPa and temperature range 400 degree Celcius through 1000 degree Celius using the ideal gas equation
but i got the error where it said "Index exceed the number of array elements(4) so I confuse about this error
fid = fopen('abc.txt','w');
Vact= [31.06300,40.29600,49.52700,58.75800;
6.209400,8.057700,9.904700,11.75130;
0.306610,0.401110,0.494380,0.587210;
0.073430,0.098860,0.122920,0.146530;
0.039958,0.055665,0.069856,0.083571;
0.026436,0.038378,0.048629,0.058391];
P = [0.01,0.05,1,4,7,10];
T = [673.15,873.15,1073.15,1273.15];
for i=1:6
for j=1:4
vol(i,j) = ((0.000461631).*T(j))./P(i);
end
end
% Calculate %error
for i=1:6
for j=1:4
error(i,j) = 100.0*(vol(i,j)-Vact(i,j))/Vact(i,j);
end
end
5 comentarios
Stephen23
el 25 de Jun. de 2020
You definitely should NOT name any variable error, as this shadows the very important inbuilt error function.
Respuestas (1)
Urmila Rajpurohith
el 30 de Jun. de 2020
yes,you can replace the variable error with any other variable name;
The best suggestion is not to use inbuilt function names as variable names.
To check if any variable share a name with a built-in function you can use the which function.
For example :
>> error = 2;
>> which -all error
error is a variable.
C:\Program Files\MATLAB\R2020b\toolbox\matlab\connector2\logger\+connector\+internal\Logger.p % Shadowed connector.internal.Logger method
C:\Program Files\MATLAB\R2020b\toolbox\simulink\dependency\analysis\@dependencies\error.p % Shadowed dependencies method
built-in (C:\Program Files\MATLAB\R2020b\toolbox\matlab\lang\error)
% Shadowed
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!