×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Array comparisons
2

Array comparisons

Array comparisons

(OP)
I am new at arrays in Mathcad. How can you compare the corresponding values in 2 arrays and write the maximum of the 2 to a new array?

For instance I have an array called "a" which has 1 column and 3 rows. I want to compare each value to the same position in "b" and write the maximum for each position to a new array called "c".

When I use c=max(a,b) it just returns one value for "c" instead of a new array.

RE: Array comparisons

Do it for each element ....

i:= 1..rows(a)
c:=max(a[i,b[i)

Rick D.

RE: Array comparisons

Type c:max(a,b) select the entire max(a,b) expression and type <ctrl><minus>, which will vectorize the function and perform it for each element in each vector.

Also, the above posting should say c[i:max(a[i,b[i) if you want to go that route.

TTFN



RE: Array comparisons

I was looking for something like that long time ago, now i make what rd78 and IRstuff said and nothing happends, i tried to <ctrl> <minus> and the arrow won't stay on of the (a,b), look:

=========================================================

=========================================================

=========================================================


RE: Array comparisons

Try initializing c in your final attempt, which otherwise looks fine to me. ie insert c[i:0 just below i:1;rows(a)

Sorry, i don't know if that will work, it just seems likely.

Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: Array comparisons

Default array indices in Mathcad start at 0.  Therefore, the range variable i should be defined as i:0;rows(a)-1.

The error message relates to trying to access a[3 and b[3, which don't exist.

TTFN



RE: Array comparisons

Thanks to --> IRstuff

It worked!! look,.....

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources