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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Finding and Marking.

lvl107
20-Turquoise

Finding and Marking.

Hi,
I have a similar question and need help. ( WORKING ON .MCD12 )

A.PNGMark6DecNum( ).PNG

Finding the 6-decimal numbers and marking. (like as above)
Thanks in advance.
Regards, -LL-

1 ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald II
(To:lvl107)

The attached gives one possibility. Create a vector whose elements are 1 if the corresponding elements in the target vector match a given criteria (eg, have more than 3 decimal places). Then use that list to mark up the corresponding elements in the target vector.

Stuart

I don't know if it will work in M12, but it works in M11 and M15.

View solution in original post

33 REPLIES 33
StuartBruff
23-Emerald II
(To:lvl107)

The attached gives one possibility. Create a vector whose elements are 1 if the corresponding elements in the target vector match a given criteria (eg, have more than 3 decimal places). Then use that list to mark up the corresponding elements in the target vector.

Stuart

I don't know if it will work in M12, but it works in M11 and M15.

MikeArmstrong
5-Regular Member
(To:StuartBruff)

Nice explanation Stuart.

Lovely use of the mod function.

Mike

Thanks, Mike.

As I hint at in the text, it needs a bit of care in the numerical round-off region, but the numbers given are relatively easy to deal with. Perhaps somebody might like to suggest a better selection function?

Stuart

RichardJ
19-Tanzanite
(To:StuartBruff)

This marks a specific number of decimal places. It's a bit of a mixed up approach, but I think it should be reliable. It would be less mixed up if I also used string functions to find the number of digits before the decimal point, but the ceil(log) approach was the first thing I thought of and I'm too lazy to change it

MikeArmstrong
5-Regular Member
(To:RichardJ)

Nicely done.

Have a look below, should your function be:-

sss.jpg

Mike

Oops! Good catch

I just fixed it and uploaded a new version of the worksheet.

StuartBruff
23-Emerald II
(To:RichardJ)

Richard Jackson wrote:

This marks a specific number of decimal places. It's a bit of a mixed up approach, but I think it should be reliable. It would be less mixed up if I also used string functions to find the number of digits before the decimal point, but the ceil(log) approach was the first thing I thought of and I'm too lazy to change it

Do you mean something like the attached, using search?

Stuart

MikeArmstrong
5-Regular Member
(To:StuartBruff)

Very nice.

Can we stop adding additional functions / methods - I'm struggling to document all the examples

Mike

RichardJ
19-Tanzanite
(To:StuartBruff)

Something like that, yes.

Or perhaps

numdigitsafter.gif

StuartBruff
23-Emerald II
(To:RichardJ)

Richard Jackson wrote:

Something like that, yes.

Or perhaps

numdigitsafter.gif

This colonial quest for efficiency is rubbing off on you, isn't it?

RichardJ
19-Tanzanite
(To:StuartBruff)

This colonial quest for efficiency is rubbing off on you, isn't it?

Too right! One must be careful not to waste flops. Wasted flops means wasted energy, which leads to global warming and the end of the world as we know it!

MikeArmstrong
5-Regular Member
(To:RichardJ)

While I am contemplating the prospect of the end of the world like we know!!! - have we reached the maximum of Mathcad's capability on this subject????

Am I right to assume that both you and Stuart are still learning of each other?

Mike

The majority of what I know about Mathcad I have learned from others that posted to the Collaboratory. Stuart is one of many. I am still leanring. That's a good thing, because if one is no longer learning then one are either senile or dead.

StuartBruff
23-Emerald II
(To:RichardJ)

Richard Jackson wrote:

This colonial quest for efficiency is rubbing off on you, isn't it?

Too right! One must be careful not to waste flops. Wasted flops means wasted energy, which leads to global warming and the end of the world as we know it!

Is this what happened to Jean? Was he neglecting to balance his flips with some flops and getting overheated? It certainly lead to the end of the Mathcad World as we knew it. I suppose the question is are we mammals or dinOsaurs looking at that old meteor headed towards Chicxulub?

Stuart

http://www.scienceclarified.com/scitech/images/lsca_0001_0001_0_img0031.jpg

Err, Jean? Wakey, Wakey.. RUUUUNNNN!

RichardJ
19-Tanzanite
(To:StuartBruff)

http://www.scienceclarified.com/scitech/images/lsca_0001_0001_0_img0031.jpg

Jean, burying your head in the sand won't help You said the calculations showed it would miss us! I told you we should have used units!

StuartBruff
23-Emerald II
(To:RichardJ)

Richard Jackson wrote:

http://www.scienceclarified.com/scitech/images/lsca_0001_0001_0_img0031.jpg

Jean, burying your head in the sand won't help You said the calculations showed it would miss us! I told you we should have used units!

ROFLMAO!!!!

I wonder if Mr Lamb is still around? - I think he'd appreciate the astronomical and unit references.

MikeArmstrong
5-Regular Member
(To:RichardJ)

Jean, burying your head in the sand won't help You said the calculations showed it would miss us! I told you we should have used units!

Now now fellers.

Mike

lvl107
20-Turquoise
(To:RichardJ)

Richard, it seems that I understand your idea on above, so I would update my question as similar one.

A.PNGMark6DecIndex( ).PNG

( Finding the 6-decimal numbers, and Replace them by their Row-index and Marking )
Regard, -LL-

StuartBruff
23-Emerald II
(To:lvl107)

Loi Le wrote:

Richard, it seems that I understand your idea on above, so I would update my question as similar one.

A.PNGMark6DecIndex( ).PNG

( Finding the 6-decimal numbers, and Replace them by their Row-index and Marking )
Regard, -LL-

Couple of ways to get started.

1. If you use a version of a function that iterates through the vector and uses an expression involving the index, then simply replace the 'value' with the index.

2. Use a simple 'filter' functions that iterates through the 'normal' result and replaces each nested array (marked element) with its index.

Stuart

MikeArmstrong
5-Regular Member
(To:StuartBruff)

Slight alternative attached.

I have combined into one program so the function is only dependant on one pre-defined function.

Mike

Mike Armstrong wrote:

Slight alternative attached.

I have combined into one program so the function is only dependant on one pre-defined function.

Mike

Oh. I see. If somebody else suggests a new method then you can't keep up, but if Micheal suggests one ... (exit. stage right. flounce.)

I like the use of match, but it is possible to make slightly more efficient use of the results. OOIC, why did you add one to the index?

Stuart

MikeArmstrong
5-Regular Member
(To:StuartBruff)

Ok. I give up you win..... I like this game though.

I added 1 to the results just to match the original request - Just having one of those moments, sorry!!!!!!

Mike

Mike Armstrong wrote:

Ok. I give up you win..... I like this game though.

WIWAC, I only got angry with people once; I was lead on a 4 hr exercise (tracking some evaders). 10 minutes before endex, I reckoned the 'enemy' had passed through the area I was staking out and got the team to load up on the 4-tonner to head for the next point I thought the enemy would head for. The team got on the lorry, then just sat down looking inwards. Sudden transformation on my part from Mister Quiet to Raging Fury - get off your backsides and get looking . Got the enemy 2 minutes later!

So the moral of the story is "Don't give up. It ain't over 'till the fat lady sings.". It is a good game, and I draw inspiration from both your's and Richard's solutions.

So many ways to skin them, so few cats

or is that, so many ways to kill them, so few lawyers?

(WIWAC - When I Was At Cranwell)

I added 1 to the results just to match the original request - Just having one of those moments, sorry!!!!!!

Mike

Ah, OK. I assumed it was because they were using ORIGIN=1. The match solution should work, provided the function is defined where ORIGIN is 1.

Stuart

MikeArmstrong
5-Regular Member
(To:StuartBruff)

So many ways to skin them, so few cats

or is that, so many ways to kill them, so few lawyers?

Ah, OK. I assumed it was because they were using ORIGIN=1. The match solution should work, provided the function is defined where ORIGIN is 1.

ORIGIN = 1 ----- Of course.

Another moment where my brain cell got a little overloaded.

Mike

lvl107
20-Turquoise
(To:StuartBruff)

Stuart,

My MC12 can open your attached file. Because of my poor English, I don't know about "vectorize" as yet. For now, I was interesting in match function go with "on error" operator working only one vector. In your worksheet, I see that the "vectorize" operator and the Output that it produces, is a powerful tools. I will study about that. I appreciate your explanation in that worksheet.

Regards,

Loi.

lvl107
20-Turquoise
(To:StuartBruff)

Stuart,

AD.PNGMark20DecIndex.PNG

( Finding the 20-decimal numbers match ( that means the first match, the second match and so on...) (only assume), and Replace them by their Row-index and Marking ) and see the attached.

Regards, Loi.

RichardJ
19-Tanzanite
(To:lvl107)

You can't do that, because you do not have enough digits of precision. You have only about 16 digits, so 0.1+1*10^-20 is just rounded off to 0.1 when it is stored.

StuartBruff
23-Emerald II
(To:lvl107)

Loi Le wrote:

Stuart,

AD.PNGMark20DecIndex.PNG

( Finding the 20-decimal numbers match ( that means the first match, the second match and so on...) (only assume), and Replace them by their Row-index and Marking ) and see the attached.

Regards, Loi.

As Richard says, the numeric processor won't handle that many digits due to the (IEEE standard) floating-point format that Mathcad uses to store numbers. OTOH, you could use the symbolic processor ...

Stuart

MikeArmstrong
5-Regular Member
(To:lvl107)

It might be worth creating a document of all your latest requests. Each request is similar and would make it much easier if augmented into one document with a brief explanation of how each function works.

You can create it or I will for you.

Cheers

Mike

Top Tags