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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Finding match.

lvl107
20-Turquoise

Finding match.

Hi,

I have a question need help. This question is similar the one in the past.

( Find the indices of the same numbers in the other set ? )

( A B).PNGFind_match(A,B).PNG

( or similar output like the above. )

Thanks in advance.

Regards, -LL-

ACCEPTED SOLUTION

Accepted Solutions

Try this worksheet. Saved in M12 format.

I have also attached an image.

Mike

Message was edited by: Mike Armstrong - Worksheet updated to suit Richards comments.

View solution in original post

20 REPLIES 20

Something like the attached?

Mike

lvl107
20-Turquoise
(To:MikeArmstrong)

Mike,

My Mathcad 12 can not read that function, and show as the following :

Find_match1.PNG

Thanks again. Regards. -LL-

Try this worksheet. Saved in M12 format.

I have also attached an image.

Mike

Message was edited by: Mike Armstrong - Worksheet updated to suit Richards comments.

lvl107
20-Turquoise
(To:MikeArmstrong)

Mike, my Mathcad 12 works with this replacement.

Find_match3.PNG

I was interesting in the function that you wrote here with this model.

Thanks a lot indeed.

Regards, -LL-

Weird. I have had Mathcad 12 so maybe someone who did can shed some light on this.

Least you've got your answer.

Mike

The first time though the loop, when it sees c[rows(c) it is picking up on c being defined as the speed of light. Change c to C and it works.

Cheers

Why is that not the case in M15?

Mike

Why is that not the case in M15?

In MC13 it looks for a global defintion of the variable, and if it finds it it uses it. In MC15 it looks only for a local defintin of the variable. See the attached sheet.

I think I need to open this in tjhe latest copy of Prime to see what it does

I think I need to open this in tjhe latest copy of Prime to see what it does

Have a look at the attached image. Prime seems to work with little c.

I don't like the way the convertor changes the program layout. Looks unprofessional and messy IMO.

Mike

Do you mean the "on error" construct? A lot of people (including me) find the current one very confusing, If I see "expression1 on error expression2" then what I would expect that to mean is evaluate expression1, and if there's an error evaluate expression2 instead. But what it actually means is evaluate expression2, and if there's an error evaluate expression1 instead. To me that just seems completely backwards! I have to think about it every time I use "on error". It's split to two lines because nested one-line "on error" and/or one-line "if" statements were also really confusing. Try nesting a one-lline "if" in a one-line "on error",. Then add another nested "if".

Richard,

The logic behind most of your explanations is fantastic. You often sway me against my own argument

The whole layout of the new programming in Prime looks unprofessional in my opinion. Looking at the image I posted above, I couldn't imagine myself producing a calculation and displaying function. With no collapsed area's available, it's going to be difficult to use Prime for most of our calculations.

I strongly dislike the double line in the programming structure too.

Mike

The whole layout of the new programming in Prime looks unprofessional in my opinion. Looking at the image I posted above, I couldn't imagine myself producing a calculation and displaying function.

It's not that different to the current look.

I strongly dislike the double line in the programming structure too.

I'll admit that I prefer the single line. And I would prefer that the lines were continuous, rather than broken. I'm not going to lose too much sleep over the current double lines though!

With no collapsed area's available, it's going to be difficult to use Prime for most of our calculations.

That's the only missing thing that would prevent you from using it?

Just me having a moan......

Mike

Nice explanation.

Bad practice though, was that seen as a bug at the time?

Mike

What was bad practice? The original behavior, the new behavior, or the fact that they changed it?

I assume that someone decided that the new behavior was preferable, but I don't personally see why. I can make MC13 behave like MC15 by adding a local assignment of 1 to v at the top of the program, so that v is a local variable that is a scalar. Or I can make MC15 behave like MC13 by adding a local assignment of v to v at the top of the program, so that the local variable v is a copy of the global variable v. So mostly it seems to me to be six of one or half a dozen of the other, except that the assignment of v to v is going to confuse a lot more people than the assignment of 1 to v. So the main thing they achieved by changing it was to break some existing worksheets.

What was bad practice? The original behavior, the new behavior, or the fact that they changed it?

Sorry, the original behavior. But you have just explained the reasoning behind the behavior.

Mike

I guess the real solution is to use good programming practice, and initialize the variables at the top of the program. If you want v to be a scalar assign 1 to v. If you want v to be a copy of the global v then assign v to v. Any programs written that way will work in both versions

Richard Jackson wrote:

I guess the real solution is to use good programming practice, and initialize the variables at the top of the program. If you want v to be a scalar assign 1 to v. If you want v to be a copy of the global v then assign v to v. Any programs written that way will work in both versions

Good advice - Or just use variables which are not globally defined

Mike

Try this one

Andy

Andy, I have learned a lot of new thing from the function you wrote here. Thanks a lot indeed.

Regards, -LL-

Announcements

Top Tags