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에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!