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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Conditional extraction of vector/matrix elements

DaveWooff
10-Marble

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

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

Yes, see attached.

Mike

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

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.

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

Mike

Wonderful, thanks for the snappy replies.

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.

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

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

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

Cheers.

Mike

Announcements

Top Tags