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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Conditional extraction of vector/matrix elements

DaveWooff
5-Regular Member

Conditional extraction of vector/matrix elements

Hi,

is it possible in one line to extract a sub-vector of all elements in another vector which satisfy some rule e.g. all elements > 0 for example?

I know how to do it in a programming loop but if there is a built in method then it's likely to be more efficient.

I can do it easily in matlab like:

z = x(x>0)

Thanks,

D

1 ACCEPTED SOLUTION

Accepted Solutions

When I look at it, that does not work. You need lookup, not match.

Attached in version 11 and version 6 (as far back as I can go) formats.

View solution in original post

13 REPLIES 13
MikeArmstrong
5-Regular Member
(To:DaveWooff)

Yes, see attached.

Mike

DaveWooff
5-Regular Member
(To:MikeArmstrong)

Hi thanks for that, however I'm on an old student version of Mathcad (OU study). Any chance you could post plain text?

Many thanks,

D

MikeArmstrong
5-Regular Member
(To:DaveWooff)

Sorry for the delay upon responding I have been out training.

See below.

Clipboard01.jpg

Mike

When I look at it, that does not work. You need lookup, not match.

Attached in version 11 and version 6 (as far back as I can go) formats.

MikeArmstrong
5-Regular Member
(To:RichardJ)

Of course. Match will return the location of the variable that meet the condition.

Mike

DaveWooff
5-Regular Member
(To:MikeArmstrong)

Wonderful, thanks for the snappy replies.

MikeArmstrong
5-Regular Member
(To:DaveWooff)

Another way, but nowhere near as elegant as Richards method. This uses user defined functions, usually located in the collasped area.

Clipboard02.jpg

Maybe Richard can saved the file down for you - if he has time

Mike

Maybe Richard can saved the file down for you - if he has time

It doesn;t take long. I would prefer to know the actual version needed though. The older the version I use to save it, the greater the risk of breaking something in the worksheet.

MikeArmstrong
5-Regular Member
(To:RichardJ)

I'm presuming that Version 6 was sufficient as he indicated that you had answered his query.

But I'll leave it down to David to confirm.

Mike

Yes, I also assume 6 was sufficient. But saving back to 6 is more likely to break something than saving back to, say, version 2000 (which was version 9).

DaveWooff
5-Regular Member
(To:RichardJ)

Hi,

yes v6 was fine, I was able to open that. The version I'm using is 2001i Professional which we get with the Open University for study, not sure what that means in terms of version numbering.

Thanks again,

D

RichardJ
19-Tanzanite
(To:DaveWooff)

That would be version 10, which was really two versions: 2001 and 2001i

MikeArmstrong
5-Regular Member
(To:RichardJ)

That would be version 10, which was really two versions: 2001 and 2001i

Cheers.

Mike

Top Tags