Plot error: Index exceeds the number of array elements (104).
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am having the following error with plotting :
Index exceeds the number of array elements (104).
Error in MUSCL_main (line 144)
plot(Ini_x,history(h).U_Euler(1,:))
The code:
Nodes = 120;
cells = Nodes-1;
Ghost = 2;
Ini_x = Cells+2*Ghost;
U_Euler = zeros(8,Ini_x);
end_time = 6.0;
t= 0;
[dt_E] = DT(U_Euler, CFL, dx, 0);
n=0;
h=1;
while (t < end_time)
for k = 1:4
[U_Le, U_Re] = MUSCL(U_Le, U_Re , U_RK_Euler);
V_EulerL = switch_Con2Prim(U_Le, Gamma, mu_0, 0);
[Flux_E] = computeFluxes(Flux_E, V_EulerL, V_EulerR, U_Le,U_Re,dt_E,dx, 0);
[Res_E] = Residual(Flux_E, dx, dy, dz, Res_E);
[U_RKe] = RK4( U_Euler, dx, dy, dz, dt_E, k);
U_RK_Euler = Boundary_periodic(U_RKe);
end
U_Euler = U_RK_Euler;
t = t+dt_E;
if mod(n,10)== 0
history(h).U_Euler = U_Euler;
h=h+1;
end
n=n+1;
end
plot(Ini_x,history(h).U_Euler(1,:)) % error
I am trying to plot the data saved in the "history"
2 comentarios
KSSV
el 6 de Mayo de 2021
The error is clear, you are trying to extract more number of elements then present in the array. Check the dimensions of each array in the data used for plot.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Scatter Plots 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!