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.

Minimum values depending on layer thickness

YA_10963798
12-Amethyst

Minimum values depending on layer thickness

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. 

YA_10963798_1-1728991682918.png

YA_10963798_2-1728991862728.png

 

Can you spot the mistake in this , please?

Thanks in advance

Yusra 

Prime 9 page 12

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:YA_10963798)

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 ...

Werner_E_0-1728995575212.png

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.

Werner_E_1-1728996635409.png

For example

Werner_E_2-1728996661917.png

Personally I would prefer to write the function just for scalars and then call it vectorized

Werner_E_3-1728996867988.png

but that may be subject of personal tast.

 

 

 

 

View solution in original post

14 REPLIES 14
Werner_E
25-Diamond I
(To:YA_10963798)

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 ...

Werner_E_0-1728995575212.png

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.

Werner_E_1-1728996635409.png

For example

Werner_E_2-1728996661917.png

Personally I would prefer to write the function just for scalars and then call it vectorized

Werner_E_3-1728996867988.png

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 

 

YA_10963798_1-1729000045071.png

How can I do this ?

 

 

Werner_E
25-Diamond I
(To:YA_10963798)


@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'.

Werner_E_1-1729004275993.png

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:

Werner_E_2-1729004343347.png

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

Werner_E_6-1729005858430.png

So one possible workaround could be that we define our own minimum function for two inputs because this function now could be called vectorized:

Werner_E_4-1729004598144.png

Bingo!

Another way, as you wrote yourself, is programming. Looping through the vectors and choosing the minimum in each turn

Werner_E_5-1729004725324.png

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.

Werner_E_7-1729005948114.png

 

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

StuartBruff
23-Emerald III
(To:YA_10963798)


@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 ...

Werner_E
25-Diamond I
(To:StuartBruff)


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.

StuartBruff
23-Emerald III
(To:Werner_E)


@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

YA_10963798_0-1729007804053.png

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

Werner_E
25-Diamond I
(To:YA_10963798)

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.

Werner_E_0-1729008238915.png

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.

 

when I tried it it gives me only the min in each matric .. not comparing like you explained
I will try it again


Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:
when I tried it it gives me only the min in each matric .. not comparing like you explained
I 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

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

@YA_10963798 wrote:
when I tried it it gives me only the min in each matric .. not comparing like you explained
I 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.


 

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

Announcements

Top Tags