Skip to main content
1-Visitor
November 8, 2010
Solved

Nested Matricies Editing

  • November 8, 2010
  • 27 replies
  • 18253 views

Hello,

I have a program I'm trying save a system states (a matrix with constituent masses for a chemical reaction) in a time-sequenced vector. I can access a single value in the nested state matrix, but I'm wondering if there's a way to edit the value without having to overwrite the nested matrix. Can anyone shed some light on this for me? I've uploaded a sample sheet that should give an idea of the error I'm running into (I'm trying to edit the 4th row cell in the nested matrix).

Thanks,

Matt

Best answer by StuartBruff

Matt Paragano wrote:

Hello,

I have a program I'm trying save a system states (a matrix with constituent masses for a chemical reaction) in a time-sequenced vector. I can access a single value in the nested state matrix, but I'm wondering if there's a way to edit the value without having to overwrite the nested matrix. Can anyone shed some light on this for me? I've uploaded a sample sheet that should give an idea of the error I'm running into (I'm trying to edit the 4th row cell in the nested matrix).

Thanks,

Matt

Andy's worksheet gives the normal solution; Mathcad doesn't allow that form of nested assignment at worksheet level (ie, := ), but it will (in some versions) allow it within a program. There is a long-standing request to allow it in an ordinary definition. The attached worksheet just expands a little on Andy's worksheet.

Stuart

27 replies

November 8, 2010

Unfortunately as I only run mathcad 12 I can't see the exact nature of your problem, but best I can offer is attached.

Mathcad allows you to index into the array to read any element that you want, but when you want to modify it thats another problem.

Hopefuly this will give you a few ideas to try, any problems save as version 11 or 12 & i'll see if there's anything else I can add.

Regards

Andy

1-Visitor
November 8, 2010

Something like the attached?

Mike

23-Emerald V
November 8, 2010

Matt Paragano wrote:

Hello,

I have a program I'm trying save a system states (a matrix with constituent masses for a chemical reaction) in a time-sequenced vector. I can access a single value in the nested state matrix, but I'm wondering if there's a way to edit the value without having to overwrite the nested matrix. Can anyone shed some light on this for me? I've uploaded a sample sheet that should give an idea of the error I'm running into (I'm trying to edit the 4th row cell in the nested matrix).

Thanks,

Matt

Andy's worksheet gives the normal solution; Mathcad doesn't allow that form of nested assignment at worksheet level (ie, := ), but it will (in some versions) allow it within a program. There is a long-standing request to allow it in an ordinary definition. The attached worksheet just expands a little on Andy's worksheet.

Stuart

1-Visitor
November 8, 2010

Weird. Your last function 'changeval' is basically the same function as I proposed and I didn't even see your sheet

Mike

19-Tanzanite
November 8, 2010

Another slight variation on the theme.

edit nested.gif

12-Amethyst
November 8, 2010

Anicillary question;

Nested arrays are mainly for holding information, and can be used to return matrices of different size from a program, But what about the memory requirements of nested arrays? Is all the information held in contiguous memory, or are the nested arrays held separatly and just pointed to from the main matrix. I am just gussing, but I suspect that they are not efficient (memory ) ways to store information?

I am thinking that it is attractive to use nested arrays to return results from a program, but for larger matrices, it might be better to just to return a large matrix and parse that, rather than parsing the nested arrays?

19-Tanzanite
November 8, 2010
Is all the information held in contiguous memory, or are the nested arrays held separatly and just pointed to from the main matrix.

That's a good question. Unfortunately, I don't know the answer. Perhaps it's possible to figure it out by creating the largest matrix possibe, and then the largest second matrix possible. Then see if you can nest them into a third matrix.