Index exceeds the number of array elements (0)

I am receiving the appended error (untitled.jpg) when I run the code in the loop which is appended as a jpg (loop where error occurs.jpg). I am also attaching the plot permeability file for reference.

4 commentaires

Ganesh
Ganesh le 14 Juin 2022
Could you please provide more details on MushyLayerOutput
Hari
Hari le 14 Juin 2022
Mushy layers are multiphase porous mixtures of solid crystals and interstitial solution with salinity or solute concentration S and temperature T, formed by the solidification of a multicomponent solution. Attached is the mushy layer thickness MATLAB file used to create output.
RAJESH
RAJESH le 7 Mar 2024
clc; clear all;
%define u
%define v
%L_i(x)=a_i(x)+b_i
format 'bank'
x=[1/4 1/2]
n=2;
for i=1:n
a(i)=x(i+1)-x(i)/0.5
end
why am i getting index exceed the number of arrays
Voss
Voss le 7 Mar 2024
Modifié(e) : Voss le 7 Mar 2024
@RAJESH: x has two elements. You try to access x(i+1) for i =1:2, but when i is 2, x(i+1) is x(3), which doesn't exist because x has only two elements.

Connectez-vous pour commenter.

Réponses (1)

The error means you are trying to index an empty array.
a = [];
a(1)
Index exceeds the number of array elements. Index must not exceed 0.
It looks like the line causing the error is from ChomboOutput
obj.levelArray(1)
You'll want to check that levelArray has been assigned values before indexing into it.

Catégories

Question posée :

le 14 Juin 2022

Modifié(e) :

le 7 Mar 2024

Community Treasure Hunt

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

Start Hunting!

Translated by