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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

fizzy
1-Visitor

Arrays

Hello to everyone...

I am trying to learn how mathcad uses arrays. I am looking at mathcad v.15's quicksheet example.

Here is an excerpt that I don't understand at all.

I am trying to create something similar myself......something simple, such as a variable with two colums and one row, but I am unable to reproduce that following the example mathcad provides. I have looked over all the help and quicksheets, but mathcad gleans over too much and doesn't come right out and specify how it is creating this kind of array --- with the braces "{a,b}" elements in the above "M" array....or matrix.

Can someone shed some light on this please? I am stuck and out of ideas on my own.

Thank you!

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:fizzy)

NO!

You see both ways to display in the last two lines of the screenshot.

1) "Expanded" NOT checked - you see just the braces telling you its a matrix and its dimensions

2) "Expanded" checked: The braces are expanded any you see the real matrices inside M

View solution in original post

24 REPLIES 24
Werner_E
25-Diamond I
(To:fizzy)

Something went wrong with the pic you tried to insert.

Please attach your worksheet.

fizzy
1-Visitor
(To:Werner_E)

Hi Werner...

Thanks for letting me know.

I was not aware it did not show in my original post.....<sigh>

Since I don't see any concievable way to 'attach' a file here......I resorted to taking a screen-shot. It seems the only way to do it ----- [?]

program.jpg

Werner_E
25-Diamond I
(To:fizzy)

To attach files you have to chose "Use advanced editor" at the upper right, then you are given the opportunity to attach files at the end of the post. Alternatively you can post, "Add Reply" and then immediatly chose edit - thos brings you in advanced editor, too.

The braces you see in the evaluation of M are just an indicator of nested arrays. {2,2} means that this is a 2x2 matrix, but thats explained in text next to the expression anyway. You can try to double click the result (or chose Format Result from the menu) and then in tab "Display Options" check "Expand nested arrays".

fizzy
1-Visitor
(To:Werner_E)

Oh....I did nont even notice the Advanced Editor there, thank you.

I attached the file, just in case.

I guess I don't understand how this matrix (with the braces "{..}") is entered as opposed to any other matrix with numbers or variables in it. Is it something you have to build in the way it appears in the program, or can you create it from scratch and enter your own values in the placeholders ----- {a, b} ?

Werner_E
25-Diamond I
(To:fizzy)

What you attached is part of the quicksheet, not what you tried to do and which failed.

Did you read what I wrote and what the help says about {2,3}, etc.?? Its nothing you type in. And if you want to create nested arrays without range variables and/or programs, you would have to create the inner matrix in a scratch area and copy and paste it in a placeholder of the outer. What exactly are you trying to do?

fizzy
1-Visitor
(To:Werner_E)

Hi again...

Yes, I attached the portion of the quicksheet just as convenience if it was needed....and if not that's ok.

I'm just trying to learn what these are. I was working with matrices and experimenting and was going through some of the tutorials and quick sheets when I ran across this nested array business.

Yes I read what you wrote, but it didn't answer my question.

If I create a 1x2 matrix say: B = |a b|, you're saying that "a" and "b" are both matrices as well? And mathcad indicates that with the braces?

You see....originally I thought I had to type the braces in myself, which obviously does't work, and that is why I wanted to understand what's going on, becasue the information in mathcad's help file isn't very helpful.

I'm fine with matrices in general, it's mathcad's execution of this type that I am not understanding.

Werner_E
25-Diamond I
(To:fizzy)

If I create a 1x2 matrix say: B = |a b|, you're saying that "a" and "b" are both matrices as well? And mathcad indicates that with the braces?

Only if a and b are matrices themselves. Then you would create a nested matrix and you can decide in the display options if MC should expand the nested arrays or not.

nested.png

fizzy
1-Visitor
(To:Werner_E)

Ok.....so keeping this example going, if the display options were set to 'expand' then MC would show the contents of those matrices with the braces.

If the options were not set as such, then you would only see the variable representations --- "a" and "b" in this case.

?


Will experiment with that a bit.

Werner_E
25-Diamond I
(To:fizzy)

NO!

You see both ways to display in the last two lines of the screenshot.

1) "Expanded" NOT checked - you see just the braces telling you its a matrix and its dimensions

2) "Expanded" checked: The braces are expanded any you see the real matrices inside M

fizzy
1-Visitor
(To:Werner_E)

Ok....I understand what you're saying now, and I can now understand what MC was *trying* to say, but never really did. This is what I needed.....thank you very much for being patient. Your example helped. I didn't look as closely at it last time, because I thought I understood, but didn't.

Thank you

rgrauslys
1-Visitor
(To:fizzy)

Bit stymied here,

just want to reach individual elements in the nested matrices...

i.e matrix is [200,200,25], and I can reach the 1x25 vector with the usual M[i,j] 2D addressing convention

Would be very simple with 3d array addressing... e.g. M[i,j,k], but Prime's convention, though clumsy, should work

the manual's suggested short cut keystroke doesn't seem to work (ie tried these: "Control" + "5";  "Control" + "shift" +"5"), Prime 3.1 ignores the typed shortcut in all the syntax permutations I've tried. Anyone find a clear example of the proper syntax?

RICHARD GRAUSLYS wrote:

Bit stymied here,

just want to reach individual elements in the nested matrices...

i.e matrix is [200,200,25], and I can reach the 1x25 vector with the usual M[i,j] 2D addressing convention

Would be very simple with 3d array addressing... e.g. M[i,j,k], but Prime's convention, though clumsy, should work

the manual's suggested short cut keystroke doesn't seem to work (ie tried these: "Control" + "5";  "Control" + "shift" +"5"), Prime 3.1 ignores the typed shortcut in all the syntax permutations I've tried. Anyone find a clear example of the proper syntax?

Select the M[i,j] then index that as you would normally do.

Here's how to do it in Mathcad 15 (I haven't got Prime).

Stuart

Thought it would work the way you show, not sure why Prime 3.1 won't allow it (my keystroke syntax must be messed up).

looks like the same syntax, no joy is all typing permutations tried.

Nothing like software to make one feel stoopid.

looks like this in prime 3p1.png

Werner_E
25-Diamond I
(To:rgrauslys)

The problem you experience in your screenshot stems from the fact, that a vector in Mathcad always has to be a column vector. With just one index you can only address single elements of a column vector!

Your k is a row vector and so you need to provide both indices to access a single element, even though the first index must always be 0.

Compare with

Regards,

Werner

Thanks!

RICHARD GRAUSLYS wrote:

Would be very simple with 3d array addressing... e.g. M[i,j,k], but Prime's convention, though clumsy, should work

You'll probably receive a warning from one or two of the long-standing members about mentioning Multi-Dimensional Arrays (MDAs) when I'm around - not to mention my cardiologist and my psychiatrist (for the sake of the latter's health, not mine), and the local police or special forces firearms response teams. 

I've only been requesting MDAs (and proper indexing) for about 16 years, and am now at the point where I think I might take The Voices' advice about cleaning the weapons 

How any modern software claiming to be "mathematical" can fail to provide proper support for MDAs is beyond my ability to comprehend - it's not like it's difficult, and there is a shed-load of libraries PTC could choose from if they didn't want to write their own.

Stuart

understand, regrets all around.

still stuck on the issue. Longtime user of older versions and trying to switch to Prime.

I'm trying to run nested calculations (i.e. monte carlo), simply can't figure out the proper keyboard syntax to address an individual nested array element inside a programming loop. I'm trying hard to resist the urge to use Matlab, love Mathcad to "quick prototype" stuff. Though now not seeming quite so quick...

Where's your shield, Stuart ?

StuartBruff
23-Emerald III
(To:VladimirN)

VladimirN. wrote:

Where's your shield, Stuart ?

Мой щит? Lost it on the MDA battlefield somewhere, Vladimir.  It disappeared somewhere into the 4th dimension and I couldn't get it back - no index.

(It's because I used my work account to reply to Richard, rather than my personal account)

Stuart

Scottish knights must always be alert, especially during working hours.

StuartBruff
23-Emerald III
(To:VladimirN)

VladimirN. wrote:

Scottish knights must always be alert, especially during working hours.

Be Alert!  We need more Lerts!

Stuart

(I'm half-Welsh (Я наполовину валлийский??), which means long-range weapons are more my style, anyway! )

WELCOME/CROESO - WARBOW WALES

Битва при Азенкуре — Википедия

Image result for welsh longbow dragon

StuartBruff wrote:


... Я наполовину валлийский??...

Correctly so - "валлиец", but the language - "валлийский".

StuartBruff
23-Emerald III
(To:VladimirN)

VladimirN. wrote:

StuartBruff wrote:


... Я наполовину валлийский??...

Correctly so - "валлиец", but the language - "валлийский".

Спасибо, Владимир.

Я (надеюсь) начать курс русского языка на следующей неделе !!

http://www.rcshaven.org.uk/?l=ru

Стюарт

Announcements

Top Tags