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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Exclude some values

YA_10963798
14-Alexandrite

Exclude some values

Hi there

I want to exclude some values from d when it is bigger than the width .... I want the program to just exclude the values that do not fulfil the condition, I used this program ,but it shows strange error ...I'm sure both of them have the same units 

YA_10963798_1-1730037766728.png

How to fix this ?

 

44 REPLIES 44
StuartBruff
23-Emerald III
(To:YA_10963798)

Excellent, glad it works.  Hopefully, you'll be able to make use of any MP 10 worksheets that are posted.

 

Stuart

YA_10963798
14-Alexandrite
(To:StuartBruff)

Yes I will use them .. thanks Sturat


Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:

Do you think if I download Prime 10 my work in prime 9 will be easily transferred? or I would have to start all over again


My guess is that you won't experience any problems if you do, but then on the other hand its always a risk to change the horses in-midst of a race.

We have seen her in the forum that Prime 10 'introduced' some new bugs, some of which were fixed in the current 10.0.1.0, other may still remain. As far as I am aware these bugs mainly concerned the symbolic engine (which you seem not to use anyway) and function with a lot of arguments. The latter is something you don't use anyway as far as I can tell and seems to be one of the bugs already fixed in 10.0.1.0.

But you can give it a try anyway - when you install Prime 10 this does not mean that you lose Prime 9. Both versions can coexist on the same machine. Only the converter (for legacy Mathcad files) would not be able to create Prime 9 files anymore and of course once you save a file in P10 you will never be able to open it in P9 again or convert it back to P9 format!

The undocumented (and unsupported) method mentioned by DJNewman to turn a range into a vector by a simple inline evaluation will not work in P10 anymore. While it was illogical that an evaluation would change the data type, it was a very handy and convenient method and I would had wished that PTC would provide an as convenient built-in alternative (the various Mathcad functions have their drawback, especially when used inside a program).
But as far as I can remember, you did not use this method in your sheet anyway.

YA_10963798
14-Alexandrite
(To:Werner_E)

Hi Werner @Werner_E 

I'm trying to show the results the same way you did , but error occurs . It didn't work once I add "row" , though I used your way and Stuart way , 

 

YA_10963798_1-1730193289701.png

YA_10963798_3-1730193620503.png 

this is result3 

 

YA_10963798_0-1730193242252.png

I need to show the rows of the results and then draw it the same way you draw the this one , but only with the selected values 

 

YA_10963798_2-1730193454137.png

 

can you show me how ?

Werner_E
25-Diamond I
(To:YA_10963798)

This is now not a question concerning "Exclude some values", isn't it.
It rather a question belonging to the thread about the nearest point.

I was not ware that you also needed the rows number of that nearest point because you did not specify it in your intial posting there. You just said that you need the nearest point and the distance.

Its not difficult to modify the functions to also provide the index of the point.

Here done with the first 'table' (function 'getNearest') I provided in that thread

Werner_E_0-1730204275469.png

 

YA_10963798
14-Alexandrite
(To:Werner_E)

Ok that was easy... I spent 2 hours thinking how to do that hhh . I even wrote different function.. Thank you

YA_10963798
14-Alexandrite
(To:Werner_E)

Werner, I'm so sorry to ask so many question...I promise this is my last question in this thread 

I'm trying to write a new program to show the selected points ... the word "result 3" is the exclued values... but obviously what I wrote  is wrong

I'm trying to write the same program , so then I can plot it as we draw it before ..

YA_10963798_0-1730212835553.png

I want to show the selected values in different color in this plot 

YA_10963798_1-1730213020424.png

 

 

Werner_E
25-Diamond I
(To:YA_10963798)

The plot I made out of fun was meanly meant to be used for my demo data with just a couple of points in each vector. It should demonstrate that its possible that two or more points in A have the very same minimal distance from a point in C as the question as to what to do in this case was not (and still isn't) answered. My "table" used just the first of the multiple point which may be possible, "table2" would show all of them which is the reason why the "A point list" in table2 are vectors as there could be more than one nearest point for a specific C-point.

So the reason for the plot was not only to show the points but mainly to connect corresponding points with straight lines.
This did not make much sense with the original data so I zoomed in by adjusting the axis limits manually (Prime unfortunately does not offer a zoom facility).
Without zooming it would look like this. The connections between the corresponding points would not be seen.

Werner_E_0-1730225652086.png

 

I also noticed that with the Excel data you provided there is no single point in C with more than only one nearest A-point. If this is always so for sure or if it suffices to use the first one if there would be more than one point with different input data, I guess that "table" is preferable over "table2" because its not nested and so makes for a nicer display. Of course  there may be reasons for rather using  a structure as in "table2" or as the one Stuart had provided. Its up to your choice.

 

Concerning the plot I am not sure what you would like to plot.

I have not looked into detail in the sheet you posted last as it was a bit too confusing for me with all the different suggestions for the nearest points mixed up.

I look at result3 now and its just a vector of 1308 distance values. So what exactly would you plot here? I am not sure what you would like to see in the plot.

Guess you would first decide upon the data format for A and C.CPT you want to use (either still nested or flattened), decide on one of the methods to create the nearest point list and then chose a way to extract whatever points or distances you need.

Maybe cleaning up the worksheet in this respect would help.

Form the picture you posted its not clear to me what your function "new" is supposed to create with its three nested for-loops.

Werner_E
25-Diamond I
(To:Werner_E)

Maybe now we are back to the subject of this thread as i think that you not only want to delete some valued from the min-distance vector but you also would like to keep the corresponding point coordinates as well.

So I modified my "exclude" function to work on matrices. You have to provide the column index of the column you want the boolean function to be applied to.

Werner_E_0-1730228144506.png

Given that  matrix

Werner_E_1-1730228196306.png

and applying this boolean function

Werner_E_2-1730228243485.png

to column 6 ("distance"), we get

Werner_E_3-1730228285817.png

Werner_E_4-1730228315237.png

To get rid of the header we can modify the boolean function

Werner_E_5-1730228388689.png

Werner_E_6-1730228400721.png

Werner_E_8-1730228438663.png

Now you could plot all C-points (green) with a minimum distance to A greater or equal as width (45.3 m).

Werner_E_9-1730228554664.png

The reason for this undesired zoom chosen by the plot is that the origin is one of the C.points. I am not sure if this is as it should be.

Werner_E_10-1730228648614.png

So to get something more visually appealing we again have to manually change the axis limits

Werner_E_11-1730228711969.png

 

One thing I noticed is that the number of entries in your "result3" and in my "raw" differ significally!

Werner_E_12-1730229244655.png

This could mean that my way of calculating the minimum distance in getNearest might  be wrong?!?
You'll have to double check. I did not bother follow up to look where the vector d would come from, etc.

Your sheet definitely needs a heavy cleanup, I think.

 

EDIT: Just noticed that you uses <= in your boolean function while I used <. But this seems to have no effect anyway because there seems to be no min-distance of exactly 45.3 m.

 

 

 

 

YA_10963798
14-Alexandrite
(To:Werner_E)

Hi Werner, 

Thank you for your reply. 

I think the reason I get different numbers in (result3)  is because I changed the equation I wanted to spot the selected and you spot the excluded values >> both of them works for me . 

 

for the plot  is incredibly impressive and showed we are in the right track. 

However, why do you think my plot looks different than yours?

YA_10963798_0-1730267694953.png

YA_10963798_1-1730267753965.png

 

 

 

Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:

Hi Werner, 

Thank you for your reply. 

I think the reason I get different numbers in (result3)  is because I changed the equation I wanted to spot the selected and you spot the excluded values >> both of them works for me . 

 

for the plot  is incredibly impressive and showed we are in the right track. 

However, why do you think my plot looks different than yours?

 

 


Ahh! I did not see that the numbers I posted (1308 and 720) would perfectly add up to the total number of C-points (2028)! 🙂

You plot looks different because you forgot to set the Line Style to "none". That way Prime connects the points.

I already mentioned that the origin (0;0) is one of the C-points and it looks for me that this should not be that way. Thats the reason Prime scales the plot so that this point at the lower left is also part of it and therfore the main data is so tiny at the upper right.

YA_10963798
14-Alexandrite
(To:Werner_E)

I see .. Thank you I corrected that

YA_10963798
14-Alexandrite
(To:Werner_E)

Hi Werner, 

Actually what I need is to show in the plot  all the points and then color the ones we selected which there distance is less than 45.3m in different color. 

So it is easy for anyone to grab the idea that there is this amount of CPTs are exlculded from the plot rather go to check each single distance. 

 

in the new plot it is okay if we don't show the distance , but I need to show the one selected. So, let's say A points in blue, Exclued C points in red and the rest of point C in green. Is that possible?

Thanks @Werner_E 

 

Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:

Hi Werner, 

Actually what I need is to show in the plot  all the points and then color the ones we selected which there distance is less than 45.3m in different color. 

So it is easy for anyone to grab the idea that there is this amount of CPTs are exlculded from the plot rather go to check each single distance. 

 

in the new plot it is okay if we don't show the distance , but I need to show the one selected. So, let's say A points in blue, Exclued C points in red and the rest of point C in green. Is that possible?

Thanks @Werner_E 

 


Yes, and you actually already did in your plot.

After choosing a Symbol for each plot as you already did you simply have to change the line style to "none" so that only the points are plotted without connecting them.

And then color the second and the fourth plot in blue as these are the A-points corresponding to the plotted C-points.

That way only the 2028 A-points which correspond to one of the C-points are plotted.

If you need to plot all 3146 A-points, you simply delete the second and fourth trace and plot second column of A over first column of A as a third plot.

Your points are quite close to each other so in a plot which shows all of them the points will overlap.

One has to be careful concerning the order the traced are created. The last plot will overlap the others and I found no way to change that order (other than redoing the plot from anew).

 

As already written above, the data for C.CPT includes the origin (0;0). This is the reason why Prime choses the zoom in a way so that this point is included in the plot, resulting in the main data to be shown very tiny at the upper right.

As i thought that its not as intended that the origin is part of the c points, I investigated and found that the origin is part of the C data not once but even nine times at different rows.

Werner_E_0-1730288921829.png

In the attached sheet I got rid of these entries by using the trim command

Werner_E_1-1730288979046.png

You used absolute values when you used the submatrix command. As table2 would have a lower number of rows now, this command would fail. I changed it to be aware of the row number of table2.

Werner_E_2-1730289103578.png

Now that the origin is not part of the dataset anymore, Prime automatically chooses a more appropriate zoom and we don't have to manually 'zoom' by changing the axis limits

Werner_E_3-1730289351158.png

or that way

Werner_E_0-1730290472388.png

 

 

Prime 9 sheet attached

 

 

YA_10963798
14-Alexandrite
(To:Werner_E)

I just saw your reply. Thank you so much Werner. I wish I can send you a gift .. 

Yusra 

Announcements

Top Tags