Filtering a range variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Filtering a range variable
Helo folks!
Please see the attached file.
How can I filter the range variable or vector so that it basicly creates a new one but for values greater then, let say 9 (like in the file attached) it returns 9 for all remaining values in the range.
Please help.
Thank you.
Solved! Go to Solution.
- Labels:
-
Physics
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Perfect! 🙂
So the number in the brackets controls the limiting value and in the same time it names the new vector?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Second and improved version.
I have used the match function to find the indices in v which are greater than z.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanx one more time 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
No problem at all and welcome to the forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Careful! You run into problem if no element in v is greater than z as match will throws an error then. Use "onerror".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Werner Exinger wrote:
Careful! You run into problem if no element in v is greater than z as match will throws an error then. Use "onerror".
Well spotted.
Version 3 attached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Mike
can you see the file attach.
Same problem only I add variable alpha.
How to tell Mathcad that if aplha=90deg use same filtering but this time apply it to vector C.
@Werener
Can you post an egsample of what you ment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Use my latest example with the 'onerror' function.
I have divided alpha by 'deg' as Mathcad will treat it a 0.524rad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Have a look at the attached worksheet for an example of what Werner was refering to.
Without the 'onerror' function Mathcad returns the error message 'no matches found'. The 'onerror' function traps this and returns the comparison vector.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Ok but is there any way for my question from "Jun 18, 2014 3:09 AM"
How to tell Mathcad that if aplha=90deg use same filtering condition but this time apply it to vector C and not to vector B.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How about the attached?
I have augmented the data.
Is this what you want?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
But none of your data will be filtered when alpha is 90deg - is this really what you want?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Ive explined it wrong.
Look at my file previously attached for vector D(10)
When alpha is not 90 deg then the D(10) vector should contain values 4,5,6,7,8,9,10,10,10,10,10- 11 values that are created filtering the B vector
When apha is 90 deg then D(10) vector should contain values 0,5,5,5,5,5,5,5,5,5,5 - 11 values that are created by filtering C vector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Yes that it! 🙂
1.)So you had to first create an augmented vector BC and then define conditions?
2.)Is there any possibility that you dont need to create the BC vector so that Mathcad uses only B and C vectors.
Ive tried something (see file attached) but it does following mistakes:
when alpha is not 90 deg it does the filtering on vector B and C so the result vector D(10) has 22 results instead of 11 results.
When alpha is 90 deg it only displays 2 results wich are correct but additional 9 are missing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
1.)So you had to first create an augmented vector BC and then define conditions?
2.)Is there any possibility that you dont need to create the BC vector so that Mathcad uses only B and C vectors.
Yes see attached. I must have had a moment when I suggested that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hats of to Mike Armstrong! 🙂
Mike can you explain a bit this programing lines, how they work and what every lines means.
I dont wanna ask you a question when something has to modified in the conditions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Have a look in the attached. Hope it makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Damn, Ill have to read this few times.
Will report back 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I will try and expand my explanation if you are struggling.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Here is a different approach. I would prefer making the vector(s) to be filtered and also the angle arguments of the filter function:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Very nice Werner
So basically you have defined Min(x,y) as a function which allows each element of V to be looped through using Vectorize? I totoally forgot about this feature.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
This ones more complicated
See file attached.
A vector is defined with values from 0-15.
How to eg. multiply values in this vector, from 0-5 with an value A (defined previously), from 6-10 with value B, and from 11-15 with value C.
A new vector would be created, again with 15 values that were created by applying different conditions within the original vector.
Could this be done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Like so?
I have used a user defined function (vec) to create a vector instead of the range variable which you used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Mike you gotta tell me wich books youve been reading 🙂
Ive got 2 Mathcad books but NONE of them has these sort of things.
I tried adding some more conditions to your last post, wich would also include angle beta in terms but doenst work
Can you see file attached.
p.s. you defined a vector in your previous post. If this was a range you couldnt done multiplication based on statements, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Mario Pende wrote:
Mike you gotta tell me wich books youve been reading 🙂
Ive got 2 Mathcad books but NONE of them has these sort of things.
I have never really picked up a Mathcad book - most of what I have learnt has been through the forum.
Mario Pende wrote:
I tried adding some more conditions to your last post, wich would also include angle beta in terms but doenst work
Can you see file attached.
Have a look at my notes with the attached worksheet. You have duplicated the condition statements.
