Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
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
Solved! Go to Solution.
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?)
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.
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.
You might find it easier to work with the nested column vector form, depending upon your algorithm.
Stuart
Fantastic. Thank you very much.
No worries.
Here's an alternative approach using a utility function and vectorization:
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.