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
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.
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!