Skip to main content
7-Bedrock
Jun 12, 2025 5:32 PM UTC
Solved

creating a nested array

I would like to write a program to create a nested array. I have a column vector containing angle values. I want to iterate through this vector and create an array of arrays with each element being [cos(angle) sin(angle)]. I am sure this is not difficult, but the syntax is not clear to me at present. I think I have been writing python programs for too long.

Thanks in advance for any help

23-Emerald V
Jun 12, 2025 8:39 PM UTC

Written in Mathcad 10, but it should work in Mathcad 11.  Just use a direct matrix form to create your nested array pair.   If you want an indexed or programmed version, that's not a problem, but this is possibly the most "Mathcaddy" way of doing it.

 

2025 06 12 A.png

 

You might find it easier to work with the nested column vector form, depending upon your algorithm.

 

Stuart

6 replies

23-Emerald V
Jun 12, 2025 7:31 PM UTC

Do you want to create an array where each single value is nested? Or, say, an array of vectors containing the sines in a single vector, the cosines, etc? Or a nested vector containing the trig values for each element of the original vector?  Or …?

 

Out of interest, why do you need to create a nested array rather than a flst matrix?

 

(Oh, and what version of Mathcad are you using?)

Translate
7-Bedrock
Jun 12, 2025 7:56 PM UTC

I am using Prime11. Basically I am trying to create a list of lists.

 

I have a vector comprised of angular values for an element in a machine I am designing. For each angular value in this vector, I want to create another vector where each piecewise element is a 1x1 vector like this: [cos(angle) sin(angle)]. Each element is a unit vector that I will use in subsequent calculations for dot products with other similarly constructed elements. Hoping this makes sense and I appreciate you taking an interest.

 

Translate
23-Emerald V
Jun 12, 2025 8:39 PM UTC

Written in Mathcad 10, but it should work in Mathcad 11.  Just use a direct matrix form to create your nested array pair.   If you want an indexed or programmed version, that's not a problem, but this is possibly the most "Mathcaddy" way of doing it.

 

2025 06 12 A.png

 

You might find it easier to work with the nested column vector form, depending upon your algorithm.

 

Stuart

Translate
Werner_E
25-Diamond I
Jun 12, 2025 10:58 PM UTC

Here's an alternative approach using a utility function and vectorization:

Werner_E_1-1749769085079.png

 

If you more like programming, you can use a for-loop, which basically is the very same what Stuart had achieved using a range variable.

Werner_E_2-1749769360494.png

 

 

Translate