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

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

Unable to extract a value from a matrix

fahmed-2
12-Amethyst

Unable to extract a value from a matrix

Greetings all,

 

I am trying to extract value  from a randomly defined matrix but I am unable to do so. I have attached the file and image for reference. Please help.

 

fahmed2_0-1688674018788.png

 Thank you,

 

ACCEPTED SOLUTION

Accepted Solutions
ttokoro
20-Turquoise
(To:ttokoro)

8 REPLIES 8
ttokoro
20-Turquoise
(To:fahmed-2)

image.pngimage.pngimage.png

ttokoro
20-Turquoise
(To:ttokoro)

image.pngimage.png

Perez
12-Amethyst
(To:fahmed-2)

As @ttokoro  has illustrated, you should first assign the function to a variable and then evaluate it. Once you've done this, you will be able to access the elements:

EP_10515634_1-1688685988993.png

EP_10515634_2-1688686000710.png

 

EP_10515634_0-1688685972814.png

EP_10515634_3-1688686024738.pngEP_10515634_4-1688686038861.png

EP_10515634_5-1688686050919.png

EP_10515634_6-1688686062185.png

EP_10515634_7-1688686100441.png

EP_10515634_8-1688686117258.png

 

 

 

 

 

Werner_E
25-Diamond I
(To:fahmed-2)

What you defined is not a matrix or vector but a range. A range can be seen as sort of implicit loop and not as a collection of values. So you can't access individual values like you can do with a matrix/vector.

Its a pity that in Prime there is no difference between the display of a vector and that of a range - they look the same and this always has resulted in some confusion. You sure are  not the first to fall into this trap.

Ranges should be used just for three purposes:
.) as abscissa values for plotting a function
.) in a prgram when using a for-loop
.) to index the elements of a vector or matrix

 

What @ttokoro and @Perez  had shown is an undocumented trick to turn a range into a vector by so called inline evaluation (evaluation by adding an equal sign at the end of a definition)

Werner_E_0-1688689543735.png

The screenshot is of Mathcad 15 and as you see in this version there was a little difference between the display of a range and a vector. Nonetheless ranges got confused with vectors in this version, too.

Using an undocumented trick may be a bit dangerous as it can change its behaviour without any notice in future versions. But I alsi use this trick ever so often because its so convenient 😉

 

@ttokoro also provided a more "legal" way to create a valid vector and there sure are different ways to create a valid vector. If you search the forum you will find different utility functions to create a vector, either by providing start, second and last value as with a range definition, or start and end value and number of elements or start, step width and end value, ...

 

fahmed-2
12-Amethyst
(To:Werner_E)

Thank you @Werner_E , @Perez  and @ttokoro for your generous solution. I am trying to make a soil settlement calculation sheet based off mathcad. I am having some issues in getting the total depth of soil thickness beneath the footing. In my worksheet, what I have done is if the footing base rests on the top surface, the value of FB is "-1" and "0" and so forth for the layers from top till bottom. I made a variable "z.depth.below.footing" to find the total soil thickness below the footing base.I realized when I put FB=0, it means that the footing base is resting on the first layer. It means it should have only two layers  beneath the footing base. However, inthe the sheet I see an extra value of "0" in the "z.depth.below.footing" output matrix. Please advise how to solve it.

 

fahmed2_0-1688774556828.png

 

Thank you

 

Werner_E
25-Diamond I
(To:fahmed-2)

Maybe that way? Is this what you are looking for?

Werner_E_0-1688784158000.png

Your approach works equally well if you shift the indices of value accordingly

Werner_E_1-1688784423975.png

or, maybe simpler and straightforward, leave your approach unchanged and simply cut off the values below index i.f.base using the submatrix() function:

Werner_E_3-1688784645744.png

And her two last ones 😉

Werner_E_0-1688785374133.png

Werner_E_1-1688785389489.png

 

 

 

 

 

 

 

fahmed-2
12-Amethyst
(To:Werner_E)

Thank you @Werner_E . It works awesome. I am facing with a different issue right now with my sheet. In the attached image, you will see the black labels which are different layers and each layer will have a random thickness. There is a separate entity, labeled as red and will have a random dimension. I am trying to discretize the layer based of where the red dimension ends from the top. In the picture, you can see that the line stopped at layer (ii). My first goal is to split the layer (ii) based on how wide the red line is. In the following: Layer (i) will be 2 feet thick, but layer (ii), where the red line stopped, will be 1 foot thick and 2 feet thick. Next, I need to find the middle point of all the layers, including the new ones. I want it to be random for any size red line and any number of black levels. The problem I'm having is that I can find the layer thickness and midpoint until the next layer after the discretization, but I can't keep track of the measurements after that. In this case, I can find the dimensions and midpoint up to layer (ii), but I make mistakes for layers (iii) and (iv). Please help.

 

Thank you

Werner_E
25-Diamond I
(To:fahmed-2)

I don't understand what you write about midpoint and mistakes in higher layers.

Here are two function which should do the splitting if necessary  (as I had understood it).

BTW, I think its time to open a new thread as we are far away from the original thread subject now

Werner_E_0-1688911868600.png

 

Werner_E_1-1688911900352.png

Attached sheet is in Prime 6 format

Announcements

Top Tags