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

Newbie

## Could you help me to caculate with nested array?

1. Is it right nested array in right picture?

2. If It is right, why did I can't caculate under fuction?

I don't know well about "nested fuction'

so I tried to find matarials about it.

But I couldn't find it.

14 REPLIES 14

## Re: Could you help me to caculate with nested array?

It looks like your vectors are nested, but you functions don't appear to take any account of this. A nested array is an array which contains other arrays. Lookup functions only operate on the top level elements of an array and expect to find scalars, not vectors. To make your functions work, you need to "unnest" your "subvector", so the lookup functions can see its elements. Eg, cc[0 (or cc[1, depending upon your ORIGIN).

Stuart

## Re: Could you help me to caculate with nested array?

I am sorry. I can't uderstand well...

the top level elements of an array>>>>> what is the meaning?

you need to "unnest" your "subvector">>>>

I search for "unnest and subvector" in "mathcad help".

But I can't find them. so could you explain more?

## Re: Could you help me to caculate with nested array?

Hmm, tricky without Mathcad to hand, but ...

Create a blank matrix from the menu. It doesn't matter what size, but 3x3 or 3x1 will do. You should see a matrix with empty placeholders ready for you to enter data into. These placeholders are what I call the "top level" elements. Normally you would put scalars, strings or even function names in the placeholders. Such an array is called a "flat array", the kind you see in most maths books, and Mathcad's function expect to operate on such arrays.

However, you can also put a vector or other array, into a placeholder. When you do this you create a "nested array", even if only one element is a vector and the rest are scalars. In fact, you can even put a nested array into a placeholder.

What I call "unnesting" is getting a nested element (vector, matrix or nested array) from the main (or "top level") array. So, for example, if a vector v has v[2 set to another vector, then you unnest it by simply referring to its index, eg w:=v[2.

Stuart

## Re: Could you help me to caculate with nested array?

thank you

actually I can't understand well. But it is useful for me.

## Re: Could you help me to caculate with nested array?

 jinsuk Lee wrote:1. Is it right nested array in right picture?

Mathcad is just showing you what you had created. It looks like you had put the READEXCEL commands in square brackets and that creates a vector consisting of the result of the READEXCEL command, which is a vector, too. So you have created a 1x1 vector whose only element ist the vector of values read by READEXCEL.

I see no reason why you would do this and maybe it was a mistake that you typed those square brackets.

 2. If It is right, why did I can't caculate under fuction?

This was already explained by Stuart. rc is a 1x1 vector whose only element is a 17x1 vector.

lookup() looks at rc to find the value 2.8667 m but all it finds is the one 17x1 vector (it only looks at the top level elements and not inside that nested vector), so it fails.

So I think you should omit those square brackets you have inserted for reasons unknown to us and I suspect it was done by accident or dispair 'cause something else had not worked.

You should also delete those lookup functions as they are replaced by the interpolating functions below anyway.

## Re: Could you help me to caculate with nested array?

thank you for helping.

Actually I can't understand your advice. But I think it is useful for me.

## Re: Could you help me to caculate with nested array?

 jinsuk Lee wrote:thank you for helping. whenever I use "mathcad", I have thought that I didn't know very much about this program.Actually I can't understand your advice. But I think it is useful for me.

My advice is to delete all square brackets and both lookup functions - delete all which is marekd in yellow:

## Re: Could you help me to caculate with nested array?

okay I got it.

But If I deleteh how can i use "nested array"?

## Re: Could you help me to caculate with nested array?

 jinsuk Lee wrote:okay I got it.But If I deleteh how can i use "nested array"?

??? Why do you think you need those nested arrays you had created?

## Re: Could you help me to caculate with nested array?

Because I think it is possible to caculate each variable.

for example)

r=1,2,3,4,5

v=10,11,12,13...20

c=2,3,4,5...10

If it is "r=1", I need to caculate all values.

r=1>>v=10, c=2 r=1>> v=11, c=2

r=1>>v=10, c=3 r=1>> v=11, c=3

. .

. .

. .

r=1>>v=10, c=10 r=1>> v=11, c=10

I think it is possible when using "nested"

## Re: Could you help me to caculate with nested array?

I don't understand what you mean and what you are trying to calculate, but I am sure that when you can do it with your nested vectors, you can as easily (if not easier) do it without those nested vectors.

Anyway, if you really want to use that nested vector, the lookup routines will work again if you use rc[0 and betac[0 instead of rc and betac. I am assuminig you have ORIGIN=0, otherwise replace 0 by ORIGIN.

## Re: Could you help me to caculate with nested array?

Have you been through the tutorials? By that I mean carefully gone through them, making sure you understand each part before moving on to the next. If not, it would be a good thing to do.

## Re: Could you help me to caculate with nested array?

I did read. and I saw book "PRIM 3.0" half and I follwed it's examples

it helped me to understand, but i think i need to solve more examples

## Re: Could you help me to caculate with nested array?

You can explore "Mathcad Prime Help Center" in Mathcad Prime (key F1) and video tutorial, here: http://learningexchange.ptc.com/tutorials/by_sub_product/ptc-mathcad-prime/sub_product_id:19

Announcements