Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
I need to choose the minimum value of q depending on the layer thickness...
If the layer thickness is =< 2m the q should be the minimum value of ( q;avg or 12MPa)
if the layer thickness is > 2m q should be the minimum value of ( q;avg or 15MPa)
I tried to do it this way, but it is not working.
Can you spot the mistake in this , please?
Thanks in advance
Yusra
Prime 9 page 12
Solved! Go to Solution.
The vector q.avg which you obviously want to modify contains 12 elements.
But the vector thickness contains only 11 elements.
So its not clear which thickness should be assigned to the elements of q.avg.
I also wonder about the last entry (-16) in vector thick ...
I also don't understand your second min usage with three inputs and also not your last max/min combinations. They do not correspond to what you have explained in your text.
So just looking at what you have written that you need, it looks to me that q.avg and thick should be of the same length and that each entry in thick correspond to an entry in q.avg. And if the corresponding thick value to an q.avg value is smaller or larger than 2 m, different upper limits for q are used.
If thats true, you have to provide two vectors of equal length and the following function should do its job.
For example
Personally I would prefer to write the function just for scalars and then call it vectorized
but that may be subject of personal tast.
The vector q.avg which you obviously want to modify contains 12 elements.
But the vector thickness contains only 11 elements.
So its not clear which thickness should be assigned to the elements of q.avg.
I also wonder about the last entry (-16) in vector thick ...
I also don't understand your second min usage with three inputs and also not your last max/min combinations. They do not correspond to what you have explained in your text.
So just looking at what you have written that you need, it looks to me that q.avg and thick should be of the same length and that each entry in thick correspond to an entry in q.avg. And if the corresponding thick value to an q.avg value is smaller or larger than 2 m, different upper limits for q are used.
If thats true, you have to provide two vectors of equal length and the following function should do its job.
For example
Personally I would prefer to write the function just for scalars and then call it vectorized
but that may be subject of personal tast.
Thank you so much
Just one question about ( min function) why it works only with scalars ... whenever I want to use it with vectors or matrics it doesn't work ...
How to overcome this ?
Should I always use programming ?
For example the following program : in each (qc;gem;cor ) I have 3 matrics each one has ten values.... what I need is to write a program that will compare the both variables and choose the minimum value of each one ( compare the first raw with the first raw and chooses the min ...and so on ) ...and the result should be also one matric with ten values. However, it chooses only the minimum value of each matrics
How can I do this ?
@YA_10963798 wrote:
Just one question about ( min function) why it works only with scalars ... whenever I want to use it with vectors or matrics it doesn't work ...
The "min" function works that way because PTC had chosen to implement it that way. When you feed this function with a couple of scalars, vectors and/or matrices, it will return the overall minimum value of all of them. The same is true for other functions like "max" or "mean". Usually this isn't bad and is exactly what the user wants.
And yes, if you want something different, you have to do a little work on your own to achieve the desired effect.
Lets say you have to vectors v1 and v2 of the same length and want to create a vector similar in size containing the min value of each 'row'.
There are various ways to achieve this result.
What comes to mind is that we could use the built-in "min" function, but as you already know, this function would just return the overall minimum of all provided values:
Next idea could be to vectorize this function call. After all this is exactly what vectorization is made for. Unfortunately there are a few function where vectorization has no effect and "min" is one of them
So one possible workaround could be that we define our own minimum function for two inputs because this function now could be called vectorized:
Bingo!
Another way, as you wrote yourself, is programming. Looping through the vectors and choosing the minimum in each turn
And yes, there sure may be even other ways to skin this cat.
...and the result should be also one matric with ten values.
That's unclear to me. From what you wrote so far I would have expected that what you want to see is a nested vector which contains THREE 10x1 vectors and not just one ???
Generally I think that your various questions have a greater chance to get answered in your sense by more people if you
1) describe clearly and in more detail verbally what you would like to achieve
2) provide a short(!) sample worksheet with simple variables, stripped down as much as possible instead of providing a 20 or 30 page document with (for me) rather confusing variable names and results stemming from cascading calculations.
You should also state in each new thread from anew which version of Prime you are using even if you already told us so in previous threads. This is especially essential if you are not using the most current version.
3) Provide concrete examples with numbers which possibly show every special case that should be considered and manually write down the exact result value/vector/matrix you would like to see as a result. The more different examples the better.
Its also better not to talk about depths, forces, layers, etc. because there meaning sure are natural for you, but possible not by other people like me 😉
4) Once you got a solution you are satisfied with, you should be able to apply it to the worksheet you are actually working on. If you experience problems doing so, you still can come back and ask for help (its just now that we would need to see your large worksheet with the corresponding data file(s)).
So in case of your current question - why not simply provide a sheet (rather than just a picture) containing two nested vectors v1 and v2, each containing three 4x1 vectors.
They may be generated manually or using random numbers. And then show which data structure with which values you would like to achieve.
Here is what I understood so far from your verbal explanation. The first part not seen in he picture is just the creation of the sample data. You can see it in the attached P9 worksheet.
Thank you so much Werner,
I opened new thread because I thought it is better to do so,
I promise I will to try to ask clearly and with shorter sheets... however sometimes it is difficult to do so.
I genuinely appreciate your efforts.. you are the best
Regards,
Yusra
@YA_10963798 wrote:
I promise I will to try to ask clearly and with shorter sheets... however sometimes it is difficult to do so.
As you are probably aware, Yusra, creating unambiguous and complete specifications and defining problems exactly are among the most challenging tasks an engineer (or anyone) has to do when managing a project.
It's nice if what someone wants is precisely defined at the start, but I've rarely seen it happen - especially in industry where entire committees can argue for months or even years over single requirements (lawyers can make a tidy living doing it over single words). It's far more common for requirements to mature alongside people's understanding of the project and what needs to be done.
For example, I've got several variants of some of my go-to functions because I need something slightly different on different occasions, and what suits one need won't suit another. If I do develop a universal function, it almost always gets too cumbersome to be easily understood by an interested reader, resulting in cut-down versions tailored to given requirements (*). And I'm just doing this for fun!
Stuart
(*) Also resulting in a configuration control nightmare for me. I frequently know that I've created a function to do so-and-so, but I've got absolutely no idea which Mathcad version I wrote it in, which worksheet it's in, or which version of a worksheet I created/modified it in. One of these days I'm going to get organized!!! Maybe tomorrow ...
One of these days I'm going to get organized!!! Maybe tomorrow ...
Oh, I gave up that expectation for myself a long time ago and life is much more pleasant now.
@Werner_E wrote:
One of these days I'm going to get organized!!! Maybe tomorrow ...Oh, I gave up that expectation for myself a long time ago and life is much more pleasant now.
I'm glad it works for you. 🙂
My experiences are somewhat less positive. ☹️
Then again, I am a master of disorganization. So, there is that! 😁
Stuart
Actually what I need is something different I need the program to compare qc;gem;1 and qc;gem;2 and choose the minimum between both of them.
So , it goes to the first raw in both variables and choose the min and then goes to the second one and does the same.
but what we did is just choose the min value in each matric
So post what this would mean in context with the example with the two nested vector v1 and v2 I posted.
If my guess wasn't what you intended - what should be the result for them?
EDIT: Upon having a second look at your sheet and zooming in, it may be that you need to apply vector indices!
Can't be sure, though, as I still don't down what exactly you are looking for.
BTW, its better to use "last" instead of "length", because "length" will only work OK as long as you have set ORIGIN to 1 as in your sheet.
@YA_10963798 wrote:
when I tried it it gives me only the min in each matric .. not comparing like you explainedI will try it again
Have you added the vector index i as indicated?
We don't see what the q.gem vectors look like.
You could post the worksheet along with the current excel data sheet but you would have to clearly state which result you would like to achieve by typing in manually the desired result, so we see what kind of vectors and which numbers you would like to see.
Now it works thanksssssssssss
@Werner_E wrote:
@YA_10963798 wrote:
when I tried it it gives me only the min in each matric .. not comparing like you explainedI will try it againHave you added the vector index i as indicated?
We don't see what the q.gem vectors look like.
You could post the worksheet along with the current excel data sheet but you would have to clearly state which result you would like to achieve by typing in manually the desired result, so we see what kind of vectors and which numbers you would like to see.
Large data sets with many dependencies in their calculation chain are why I prefer to use smaller, representative data sets in a separate worksheet to address a problem. There is no test like the real data, but the process often helps clarify my thoughts if nothing else.
And, as you and other have pointed out before, it can circumvent some of the proprietary information restrictions that may haunt actual data and programs.
Stuart
Hi there ,
How are you doing , Werner?
I tried this function again , but I don't know why it shows all of the results equal to zero .. I'm pretty sure that zero is not always the min value. Do you know why?
These are the two values which i'm comparing
The data structure of the two q vectors looks unusual judged from your second picture.
It seems that its multiple times nested.
This new question nicely demonstrates what I had already stressed multiple times and what Stuart also addressed in his answer above (here). Creating a small demo sheet using with the function you use with similarly nested data would have been highly beneficial. Especially compared to just a picture where we only can guess what the data structure actually is.
The program you use would work fine if each of the two q vectors consists of a couple (maybe three) normal vectors.
But the elements of your q vectors seems to be nested as well and this may be the reason of the unexpected results.
Here a simplified example which should demonstrate the difference:
If you really need to keep this heavily nested data structure intact, you may try this modified Min2 function. Vectorization is done within this function so you don't have to use vectorization when calling it.
I guess you can use this function directly with your two q vectors as arguments and so can omit the for loop altogether. Give it a try.