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

Nested Matricies Editing

SOLVED
Highlighted
MVP
Newbie

Nested Matricies Editing

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Nested Matricies Editing

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 27

Re: Nested Matricies Editing

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

Re: Nested Matricies Editing

Something like the attached?

Mike

Re: Nested Matricies Editing

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

Re: Nested Matricies Editing

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

Mike

Re: Nested Matricies Editing

Another slight variation on the theme.

edit nested.gif

Re: Nested Matricies Editing

Thanks for the help everyone. It appears this will work backwards to at least MathCAD 11, which is what I need.

Maybe I should start a petition for the normal assignment of values in embedded matricies

Re: Nested Matricies Editing

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?

Re: Nested Matricies Editing

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.

Re: Nested Matricies Editing

I guess that answers that question.

nested memory.gif

After assigning M1, M2 is was large as I could make it without running out of memory. There is no problem if I then put bot matrices into a nested array though, so the nested array cannot occupy a single contiguous memory block.

Strangely, even though it can create the nested array OK, if you try and display it you get an out of memory error.