cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

3D iteration

jlin-2
1-Visitor

3D iteration

Dear all,

I have a problem with the 3D iteration. Firstly, I construct an initial jxk matrix. Then, I try to iterate the matrix and to build up a nested matrix. I don't understand where the problem is and I am wondering if there is a better way to program this idea. I have attached the file. Thank you very much for your kind help!! 

3d iteration.bmp

4 REPLIES 4

Valery, in your program B is just equal to MMM.  The program stops at "return MMM" and the second half is not evaluated - that's why you no longer get the error.

J J Lin, note that Valery deleted your line i = i + 1 because it does nothing.  The very next step redefines i based on your iteration from 0 to 3 (or 0 to 2 in Valery's program).

MJG
18-Opal
18-Opal
(To:jlin-2)

It's hard to follow what you're attempting to do.  What do you want as the final result?

LucMeekes
23-Emerald III
(To:jlin-2)

From Valery's reaction I infer that you've run in this trouble with your loop i 0...3.

With three dimensions you should run from 0...2, not 0...3 (that would be 4 dimensions?).

Success!
Luc

Nope. Valery's adaptation throws no error because the program is exited before it even gets to that loop.

The problem lies in the fact that you cannot refer to an array element that doesn't exist.

While you can create new array elements by just defining them, using the column indexer (<0>) may be problematic,

and  successfully assigning to individual items of a new nested matrix with (BM<0>[i)[j,k is plain impossible.

It fails already here:

Announcements

Top Tags