Turn on suggestions

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

Showing results for

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

Showing results for

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

Feb 11, 2015
10:31 PM

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

Feb 11, 2015
10:31 PM

Vectors and Matrics

If we have an arbitrary vector (V) like the one shown. Using Mathcad we want to order data from lowest to highest like the one shown on right. How would we do that?

image is attached

8 REPLIES 8

Feb 12, 2015
12:47 AM

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

Feb 12, 2015
12:47 AM

(My answer as long as everyone in Europe and America are sleeping)

Feb 12, 2015
01:36 AM

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

Feb 12, 2015
01:36 AM

Thanks for answering, however the main idea is to move down through the array comparing adjacent pairs and swapping the values if they are out of order. can you do it this way?

Feb 12, 2015
02:08 AM

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

Feb 12, 2015
02:08 AM

Zack Alhashim wrote:

Would you like to know how does the built-in function sort work?

Feb 12, 2015
02:30 AM

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

Feb 12, 2015
02:30 AM

Yes, I want the left hand side vector to look like the right hand side by swapping the values if they are out of order.

Feb 12, 2015
05:56 AM

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

Feb 12, 2015
05:56 AM

Valery is giving you the answer to your question; but he's being mysterious as well.

THe built-in function "sort" will do exactly what you're asking for: return the vector in increasing order. The syntax is exactly as Valery showed

sorted := sort(unsorted)

As for why Valery's example works, strings are ASCII code.

Feb 12, 2015
06:15 AM

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

Feb 12, 2015
06:15 AM

Zack Alhashim wrote:

You already got your solution if you just need to sort a vector.

If this is homework and your task is to provide a program in Mathcad to sort a vector using an algorithm like bubblesort, I suggest you post a Mathcadfile to show what you have done so far and where you got stuck. You don't expect us to do your home work, don't you?

You were already given advice on how to program in Mathcad in this thread http://communities.ptc.com/message/272352#272352

I guess its time to show some effort on your own now.

Feb 12, 2015
02:30 PM

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

Feb 12, 2015
02:30 PM

In case you have difficulties finding a decent sorting algorithm to implement (which is very unlikely, I guess), I'd recommend this site: http://www.sorting-algorithms.com/

You can compare different algorithms, watch animations and look at the algorithm's pseudo code.

Find attached an attempt to create that kind of animiation in Mathcad for the bubble sort algorithm.

You may play around with the attached sheet, but the sort routine is protected for obvious reasons.

Feb 13, 2015
01:41 AM

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

Feb 13, 2015
01:41 AM

One KISS-program

PS

We need **swap(a, b)** function (a procedure) in Mathcad!?