Plot error: Index exceeds the number of array elements (104).

1 次查看(过去 30 天)
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 个评论
KSSV
KSSV 2021-5-6
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.
Jamie Al
Jamie Al 2021-5-6
So, you're saying I could use U_Euler isnead to plot not the history?

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2021-5-6
编辑:KSSV 2021-5-6
plot(Ini_x,history(end).U_Euler(1,:))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by