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

Replace negative numbers in a Column Matrix with a different number.

ptc-4451268
1-Newbie

Replace negative numbers in a Column Matrix with a different number.

Hello,

I have a column of data.

If the column of data has a negative number, I would like to replace that number with a very small positive number, 10^-5.

I've attached my worksheet explaining what I want to do.

Any advice?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

and another variation in just 2 lines

IMG0001_2986093.PNG

IMG0002_2986093.PNG

IMG0003_2986093.PNG

IMG0004_2986093.PNG

View solution in original post

25 REPLIES 25

May be so:

neg2pos.png

MikeArmstrong
5-Regular Member
(To:ValeryOchkov)

How about the attached, slightly different approach to Valery's.

Mike

Here's a third method. ( wonder how many different ways we could come up with!)

Alan

MikeArmstrong
5-Regular Member
(To:AlanStevens)

Here's a third method. ( wonder how many different ways we could come up with!)

Very nice.

I always look forward to seeing your examples.

Mike

AlanStevens wrote:

Here's a third method. ( wonder how many different ways we could come up with!)

Alan

The best method is not a ***.xmcd.zip but the PICTURE

I have no time for Mathcad open, the file open (zip -> xmcd) etc for this simple task...

MikeArmstrong
5-Regular Member
(To:ValeryOchkov)

The best method is not a ***.xmcd.zip but the PICTURE

I have no time for Mathcad open, the file open (zip -> xmcd) etc for this simple task...

On that note......

Clipboard01.jpg

Mike

Valery Ochkov wrote:

The best method is not a ***.xmcd.zip but the PICTURE

I have no time for Mathcad open, the file open (zip -> xmcd) etc for this simple task...

You're right, but it's taken me half-an-hour to figure out how to do it! I've copied to Paint and saved as a .png file, but is there a more direct way from within Mathcad itself?

Alan

questionb.png

AlanStevens wrote:

Valery Ochkov wrote:

The best method is not a ***.xmcd.zip but the PICTURE

I have no time for Mathcad open, the file open (zip -> xmcd) etc for this simple task...

You're right, but it's taken me half-an-hour to figure out how to do it! I've copied to Paint and saved as a .png file, but is there a more direct way from within Mathcad itself?

Alan

half-an-minute for me

Valery Ochkov wrote:

half-an-minute for me

Hopefully, for me also in future!

Alan

and another variation in just 2 lines

IMG0001_2986093.PNG

IMG0002_2986093.PNG

IMG0003_2986093.PNG

IMG0004_2986093.PNG

MikeArmstrong
5-Regular Member
(To:AlanStevens)

Alan,

I copy and paste straight into IrfanView (Which is freeware) and save the image that make literally less than a minute.

Mike

david h wrote:

Hello,

I have a column of data.

If the column of data has a negative number, I would like to replace that number with a very small positive number, 10^-5.

I've attached my worksheet explaining what I want to do.

Any advice?

Thanks!

David, say please what is a correct answer!!!

Wow!

Thanks for all of the advice. I supposed I started a competition.

Let me take a look...

It looks like Ian's was the most straight forward, though they were all good!

MikeArmstrong
5-Regular Member
(To:ptc-4451268)

I have to disagree. He has used a range variable which I try and keep away from at all costs.

All work, so all good 🙂

Mike

I am a novice user, so I don't know the benefits of not using range variables. Why do you stay away from them? I suppose I should know.

I don't agree with Mike on this one, range variables are fine. Problems can arise when using range variables as variables, like x=2...10 and then using x in equations. Using range variables to construct x is fine.

MikeArmstrong
5-Regular Member
(To:wayne)

They are useful in some applications, but the majority of Mathcad functions work with vectors. Why define the variable at worksheet level when it can be defined within the program?

I've always tried to stay away from range variables - just a personell opinion though.

Mike

I did this a long time ago, it's a portion of an shear wall interaction diagram calc, and I would probably change some things if I were to rewrite it now, but there is nothing wrong and the use of the range variable is clear, even to someone that does not know mathcad. (Vectorizing would not be obvious to a nonuser)

Personally, I find it easier to write this way first, and if necessary, go back after it's verified to change to programs and possibly use vectorization. Debugging is a bugger.

tmp3.gif

MikeArmstrong
5-Regular Member
(To:wayne)

I do agree that in certain applications the use of range variables is valid, but as you said it comes down to personnel preference.

Mike

I agree, personal preference, and experience.

But, the range variable is getting a bat rap, it is a very powerful variable and I (and I assume many) have, and will, used it extensively. You should not try to stay away from it, just don't use it as a variable, use it as intended, an index

MikeArmstrong
5-Regular Member
(To:ptc-4451268)

As I have said below, because the majority of Mathcad functions work with vectors, which hasn't been created using Ian's method.

Mike

david h wrote:

Wow!

Let me take a look...

Russian Prince Alexei takes a look (chooses) on his bride :

brides.png

MikeArmstrong
5-Regular Member
(To:ValeryOchkov)

I think me and you were left on the stand :-).

Mike

Mike Armstrong wrote:

I think me and you were left on the stand :-).

Mike

She was Maria Miloslavskaya- see http://en.wikipedia.org/wiki/Maria_Miloslavskaya

MikeArmstrong
5-Regular Member
(To:ValeryOchkov)

Brillant.

Mike

Top Tags