Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts!
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Dec 07, 2010
04:39 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 07, 2010
04:39 PM

Calculating multiple matrices in a loop

Normally, we work with a matric which is a 2D element. (with rows and columns A i,j). However, if I were to work with generation of a few matrices in a loop, I would need another index to preserve the matrices, so that I can return a 'set' of matrices in the operation. How would someone approach this problem to return a set of matrices and hence 3D matrices in a loop or 4D matrices in 2 sets of loops?

I did a search and found a previous discussion on it.

http://communities.ptc.com/message/46160#46160

However, when I tried this approach, I am not having any success on it. Maybe I didn't put in with the right syntax? Attached is the file. Please provide any assistance or suggestion if you can. Thanks in advance.

Regards,

Charles Chan

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Dec 08, 2010
04:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

11 REPLIES 11

Dec 08, 2010
03:44 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 08, 2010
03:44 PM

Something like the attached?

You didn't define i,j or k.

Mike

Dec 08, 2010
03:47 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 08, 2010
03:47 PM

Mathcad doesn't directly support true multi-dimensional array (MDA) indexing, so the forms you've used (Ai,j,k) are invalid.

I'm afraid that you'll have to go through the kind of process you've used to create the nested matrices; I'd probably opt for writing a function to process a single array and then call that from within the loop.

You might want to look at this thread http://communities.ptc.com/message/132423#132423 . There are a couple of messages in that reference an MDA library that I wrote (just to show it could be done relatively easily) - it's generally compatible with the way Matlab does things.

Stuart

Dec 08, 2010
04:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 08, 2010
04:12 PM

A few brief notes in the attached...

~R~

Dec 09, 2010
04:14 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 09, 2010
04:14 PM

Hi,

I would like to all of you for the valuable input that I have received concerning this thread. My main goal was to have an automated program to go thru a loop "n" times to produce a set of "n" matrices based on the variable n. I was mainly interested in displaying the individual matrices M within the loop for checking purposes and to use them for further computation.

I spent some time trying out the programming in an attempt to get it working but without success for a while. Then I decided to try it using the Mathcad 14 version. I have the Mathcad 2001 version at home but have the Mathcad 14 at work. I do some programming at work and also do a lot of programming at home. Therefore, I usually default to the lower version because then it will be compatible both at home and at work, and whenever I started a program at work I can also continue working on it when I get home.

I moved the program to Mathcad 14 and found that I was finally able to get almost all of what I want working. However, I was not able to get the '3D" matrix A to displace with the individual sets of matrices using the equal sign after the logic routine. I was only able to obtain A = ({5,3},{5,3},{5,3},{5,3}).

Rich, can you please advise me as how you were able to obtain a display of the sets of matrices after A using the equal sign? I was able to display the individual matrices separately in a loop but not together within the definition of A. So for now it will suffice, but I am curious as to how one may be able to obtain the A = ( "sets of matrices on display") from the file that you sent me. Is there anything that I need to do after typing in A following the routine other than using the equal sign from the keyboard or did you use something else to get it to display?

Attached are two of my files for review. Thank you to all of you who have comtributed to this thread.

Regards,

Charles Chan

Dec 10, 2010
04:13 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 10, 2010
04:13 AM

Charles Chan wrote:

I moved the program to Mathcad 14 and found that I was finally able to get almost all of what I want working. However, I was not able to get the '3D" matrix A to displace with the individual sets of matrices using the equal sign after the logic routine. I was only able to obtain A = ({5,3},{5,3},{5,3},{5,3}).

Select A = ({5,3},{5,3},{5,3},{5,3}), then go to Format/Result/Display oprions and check Expand nested arrays.

Alan

Dec 10, 2010
09:24 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 10, 2010
09:24 AM

Thanks for replying, Alan. This is a busy time for me. Not much time for a real visit; just enough sometimes for a drive-by comment...

~R~

Dec 13, 2010
04:30 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 13, 2010
04:30 PM

Thanks Alan for the simple solution to my problem. I am still new to using matrices on Mathcad. I appreciate your help.

Regards,

Charles

Dec 16, 2010
10:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 16, 2010
10:15 AM

Hi all,

Here is a follow up on working with multiple matrices in a loop. I have a set of n matrices that I would like to 'convert' into another set of matrices using a mapping function which will determine the locations of the elements of the original matrices.

I found that I was able to accomplish it manually by doing the mapping routine one by one, matrix by matrix. However, when I tried to accomplish it in a loop to cycle thru 'n' matrices, it does not work. This goes back to the concept of working with matrices in a loop that I posted earlier. Anyone has any idea how it can be accomplished? Did I do anything work with my syntax? Please advise and thank you in advance.

Regards,

Charles Chan

Dec 16, 2010
12:50 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 16, 2010
12:50 PM

Charles Chan wrote:

Hi all,

Here is a follow up on working with multiple matrices in a loop. I have a set of n matrices that I would like to 'convert' into another set of matrices using a mapping function which will determine the locations of the elements of the original matrices.

I found that I was able to accomplish it manually by doing the mapping routine one by one, matrix by matrix. However, when I tried to accomplish it in a loop to cycle thru 'n' matrices, it does not work. This goes back to the concept of working with matrices in a loop that I posted earlier. Anyone has any idea how it can be accomplished? Did I do anything work with my syntax? Please advise and thank you in advance.

You probably need to use a program in preference to range variables, and you might be better of creating a mapping function that applies to a whole array.

See attached for one possibility.

Stuart

Dec 17, 2010
11:22 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 17, 2010
11:22 AM

Hi Stuart,

Thank you for the insight and valuable information on the looping routine with matrices and the suggestion of the application of using a function to perform the mapping.

By the way, your earlier link to a thread on the discussion of using MDA is broken. Can you attach the routine for my edification? Thank you very much.

Charles

Dec 17, 2010
12:08 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Dec 17, 2010
12:08 PM

Thank you for the insight and valuable information on the looping routine with matrices and the suggestion of the application of using a function to perform the mapping.

No worries.

By the way, your earlier link to a thread on the discussion of using MDA is broken. Can you attach the routine for my edification? Thank you very much.

One of those web oddities, I guess, as they seem to work for me (IE6 running on WinXP).

However,