Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
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.
Thank you,
Solved! Go to Solution.
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:
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)
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, ...
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.
Thank you
Maybe that way? Is this what you are looking for?
Your approach works equally well if you shift the indices of value accordingly
or, maybe simpler and straightforward, leave your approach unchanged and simply cut off the values below index i.f.base using the submatrix() function:
And her two last ones 😉
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
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
Attached sheet is in Prime 6 format