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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Table Basics

awibroe
14-Alexandrite

Table Basics

‌hi,

im trying to make the jump from excel to prime for good.

im trying to find how to create data from a table. In a very basic example if I create a 2 by 3 table with 1, 2 and 3 in the first two columns, how in mathcad do I calculate a third column that would return for example the multiplication of column 1 and 2 (appreciate this is actually column 0 and 1?

in excel I would have typed =A1*B1 and dragged down through column C. Then I could do things like evaluating the sum of any column or row. Looking to see how this is acheived in mathCaD. If there is an existing tutorial on this id appreciate being pointed in the right direction.

cheers,

andy

ps on my phone which is why this message looks like it's written by a child.

10 REPLIES 10
Werner_E
25-Diamond I
(To:awibroe)

How about something like this:

Its important to use vectorization, otherwise c is calculated as vector product (-->14)-

Its not necessary to use matrices, but if you insist you could do something like

Werner

StuartBruff
23-Emerald III
(To:awibroe)

Andy Wibroe wrote:

im trying to find how to create data from a table. In a very basic example if I create a 2 by 3 table with 1, 2 and 3 in the first two columns, how in mathcad do I calculate a third column that would return for example the multiplication of column 1 and 2 (appreciate this is actually column 0 and 1?

in excel I would have typed =A1*B1 and dragged down through column C. Then I could do things like evaluating the sum of any column or row. Looking to see how this is acheived in mathCaD. If there is an existing tutorial on this id appreciate being pointed in the right direction.

Adding to Werner's reply, there are several ways to approach this problem - the main adjustment that people need to make when moving from Excel to Mathcad is to make use of Mathcad's operators and functions and to remember Mathcad is not a spreadsheet.

Stuart

LucMeekes
23-Emerald III
(To:awibroe)

And in Prime (which many discourage to use at the moment because it is still, in many respects except a few, inferior to Mathcad 15)

using its 'table' feature, it might look like this:

But you can also use the constructs that Werner and Stuart have shown:

Note that if you buy Prime, you get Mathcad 15 for free.

Success!
Luc

awibroe
14-Alexandrite
(To:awibroe)

‌thanks to all!

a Quick question on arrays, can you only create an array of from a number to another by a given step 12345 or 2468. Or can you be more sophisticated like doubling the previous number ie 1248 etc or by some other other formula?

MJG
18-Opal
18-Opal
(To:awibroe)

An array can be anything you want:

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

Good clarification, Luc.

I also thought of one more way it can be helpful to define arrays:

(two means to achieve the same thing)

LucMeekes
23-Emerald III
(To:awibroe)

Be sure to not confuse arrays with ranges.

In the examples Mark shows, above here, k is defined as a range (it's NOT an array! Although in some respects it will behave like one. But you cannot index it, for example.)

The other elements (a, b, c and d) are arrays, they can be indexed (as it happens: all with the range k).

You define ranges (such as k) with the special construct:

<start value>, <next value>;<last value>

That is, only by addition. The step value is:

<next value> - <start value>

E.g. multiplicative and variable step sizes are not supported for constructing a range.

With arrays you can do all sorts of things, as Mark shows.

To illustrate more (f is a range, F is a vector):

Success!

Luc

RichardJ
19-Tanzanite
(To:awibroe)

a Quick question on arrays, can you only create an array of from a number to another by a given step 12345 or 2468. Or can you be more sophisticated like doubling the previous number ie 1248 etc or by some other other formula?

I don't even know what you mean by that. As Mark says, an array can be created or manipulated in many ways.

I very much get the impression that you are trying to figure out how to do things in Mathcad the same way you would do them in Excel. Mathcad is nothing like Excel though, and the right way to do things is very different. In Excel you start with an array of numbers, then you create another array of numbers from that, and so on. It works that way because it was designed as an office tool, for accountants and managers. If that's what you want to use it for, it's great, but it's a grossly inadequate tool for engineering calculations. You can't even create a user defined function without resorting to programming in VBA. Mathcad is capable of creating a series of arrays, one after the other, but it's rarely the best approach. In Mathcad creating user defined functions is trivial, and that's how you should approach most problems. Write out the problem as a series of dependent functions. Then plug the input numbers into the final function, and get the result. Unless you have some reason to view them, there's no need to calculate lots of intermediate results in a series of arrays.

StuartBruff
23-Emerald III
(To:awibroe)

Andy Wibroe wrote:

thanks to all!

a Quick question on arrays, can you only create an array of from a number to another by a given step 12345 or 2468. Or can you be more sophisticated like doubling the previous number ie 1248 etc or by some other other formula?

As Mark says, you can do considerably more complex things with arrays.

An important difference between Mathcad and Excel is that Mathcad operates on entire arrays (*).  One of the first things that new users should do is to get away from the one-cell-at-a-time thinking of Excel, and to start thinking about doing things to the whole array.  If you want to double it, you don't have to create a replica region and set each cell to =2*otherCell, you just write B:=2*A and that's it.

Learning to program in Mathcad, whilst not necessary in many instances, is useful, allowing people, for example, to write functions to generate basic lists rather than using range variables.  The function vecint below simply generates the sequence 0..N-1:

Stuart

Hi Andy -

Welcome to PTC Community; as you can see, there is lots of knowledge within.

Did one of the responses help more than another and if so, would you please mark it correct?

This way the answer bubbles up to the top of the discussion and is easily found by others.

Best,

Toby

Announcements

Top Tags