Info

This question is closed. Reopen it to edit or answer.

??? Index exceeds matrix dimensions.

2 views (last 30 days)
john
john on 9 Dec 2011
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi could anyone tell me what is wrong with my script?
I'm not bvvery good at Matlab so i apologize if this is obvious.
for i=(PRINT_TIME:PRINT_TIME:TOTAL_TIME); for j=(DELTA_TIME:DELTA_TIME:PRINT_TIME);
c=1; x(c)=2*(F*c)+(1-2*F)*c; for c=(2:N-1);
c>=(2);
c<=(N-1);
c = F*(c(c+1)+c(c-1))+(1-2*F)*c;
end;
c=N; x1=x; x1(N)=2*F(c(N-1)+B*FLUID_TEMP)+(1-2*F-2*B*F)*c;
end;
time_new=TIME+PRINT_TIME; TIME=time_new; fprintf ('T = %d seconds \n', T); disp(y) end;
  1 Comment
Dr. Seis
Dr. Seis on 9 Dec 2011
1. What variable is the error associated with?
2. Where do you define "T" above?

Answers (1)

Dr. Seis
Dr. Seis on 9 Dec 2011
You are not creating any x beyond x(1). In your inner "for" loop you have:
c = F*(c(c+1)+c(c-1))+(1-2*F)*c;
Which probably should be:
x(c) = F*(c(c+1)+c(c-1))+(1-2*F)*c;
The following are doing nothing and can be deleted:
c>=(2);
c<=(N-1);
Unless you meant to set up and "if" statement?

This question is closed.

Community Treasure Hunt

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

Start Hunting!