Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Comparing Two RV Arrays and Outputting Character S...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

03-06-2013
09:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-06-2013
09:33 PM

Comparing Two RV Arrays and Outputting Character Strings

So I'm very new to mathcad prime and I'm trying to compare resultant numbers from computing with range variables. I was hoping someone could show me how to figure out what I'm trying to accomplish.

Example (simplified):

I've defined two range variables

A:=220,320..420

B:=840,640...440

then applying some math with the RVs

C(A):=A/2

D(B):=B/4

I would then like to compare the first value of C to the three values in D and determine if it is greater than or less then the D value and then output an array with Yes if greater, or No is less than. Then repeat this with the second and third values in C respectively.

I'm thing something like this...

i=0

j=0

for i=1:3

for j=1:3

if C(i)>D(j)

E(i+j) = "Yes" %I'd like the ouput to be a one dimensional array/vector and not a two dimensional matrix

else

E(i+j) = "No"

end

end

The red boxes are the two variables I'd like to compare, and display if alpha is greater than tau in a coulmn matrix/array.

11 REPLIES 11

03-07-2013
03:34 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-07-2013
03:34 AM

The attached should help. Be careful to learn the difference between range variables and "proper" variables.

Alan

03-07-2013
02:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-07-2013
02:13 PM

Would you be so kind as to briefly describe the difference?

03-07-2013
02:39 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-07-2013
02:39 PM

See the attached articles by Stuart Bruff.

03-07-2013
02:23 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-07-2013
02:23 PM

Btw, thank you very much for the file. We're using Mathcad 15 in my Manufacturing class and my teacher is barely explaining it, and assumes we've used it a bit in other classes (while I have not). So I'm thanks the liberity to teach myself Mathcad Prime 2.0 since it's newer and available. The program is very powerful, and while my teacher wants us to compare the two angles by hand and write yes or no on a seperate sheet of paper, I figured I'd learn how to do it in Mathcad since it's possible with the programming tab anyway.

I was trying to take my Matlab experience and apply here, but was just having a lot of trouble.

Thanks again.

03-17-2013
09:25 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-17-2013
09:25 AM

Hi Matthew,

The following video tutorials for Mathcad Prime can help you learn the program:

http://learningexchange.ptc.com/tutorials/by_sub_product/ptc-mathcad-prime/sub_product_id:19

And also this tutorials (you can find them in attachment too):

http://www.ptc.com/company/community/schools/projects.htm#mathcad-prime

03-07-2013
04:45 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-07-2013
04:45 PM

By changing the D and mu RVs to Matrices it has complicated/messed up later computations

D:=220,320,420

mu:0.15,0.25..0.35

So if where to to multiply D*mu, it now returns a singular number from the dot product. But I want it to return 3 individual numbers like before.

03-07-2013
04:53 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-07-2013
04:53 PM

Matthew Machart wrote:

By changing the D and mu RVs to Matrices it has complicated/messed up later computations

D:=220,320,420

mu:0.15,0.25..0.35

So if where to to multiply D*mu, it now returns a singular number from the dot product. But I want it to return 3 individual numbers like before.

This is what vectorizing is for. If you do not want D*mu be interpreted as dot product but want the multiplication be iterated over the elelemnts of both vectors, you have to vectorize that product. You can use the Matrix toolbox or use the keyboard shortcut "Ctrl & -" to do so.

Sorry - just saw that you ar using Prime. Keyboard shortcuts are language specific here. By trial and error (the docs are wrong) I found that its Strg-Alt-6 for me. Use the the operators menu in the calculate ribbon.

03-08-2013
11:38 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-08-2013
11:38 AM

Oh....T_T that's easier... I did for loops instead for everytime i had to multiply lol.

03-08-2013
04:46 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-08-2013
04:46 PM

Matthew Machart wrote:

Oh....T_T that's easier... I did for loops instead for everytime i had to multiply lol.

Yes, but to duplicate the behaviour of the product of two range variables (which you should not use for that kind of calculations anyway) you would have to resort to loops. The results may look alike but they aren't. The latter being a full fledged vector you can reuse in a predictable way.

03-12-2013
04:29 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-12-2013
04:29 PM

Well this the final product I have as of now (see attached). Any recommendations on how to improve what I've done.

PS: I'm learning a lot from this and thuroughly enjoying it. Thanks everyone for your input!

03-12-2013
05:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-12-2013
05:34 PM

I noticed that you did not use any function but evaluated all "on the spot". Using function can be convenient in most situations and is more versatile.

I showed it as an an example with the last table. See attached