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

Oct 12, 2017
11:39 AM

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

Oct 12, 2017
11:39 AM

Assigning a variable name to the output of a solve block in Prime (inputs are vectors)

Hi, I'm trying to assign a variable to the output of a solve block but there vector inputs and the output from the 'find' function is a series of 2x1 arrays, in one long array. Sorry - it's hard to describe but an image is attached.

I've created two blocks to show the problem - the last one showing the error when I want to assign the output to a variable.

Thanks

10 REPLIES 10

Oct 12, 2017
11:51 AM

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

Oct 12, 2017
11:51 AM

Your sheet is not attached. (May need to "zip" the file to attach it.) Consider including an "XPS" file for those of us with older versions.

Oct 12, 2017
12:09 PM

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

Oct 12, 2017
12:09 PM

Take a look at the labels of "c" and "y" in the find function of both solve blocks. They appear to be different.

Note that if "c" is labeled as a constant in either solve block, Mathcad is using the speed of light.

Oct 12, 2017
01:37 PM

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

Oct 12, 2017
01:37 PM

The problem is that you are not dealing with vectors when you make your reault dependent on a range i. The result of your left solve block is NOT a nested vector and so you can't assign it a variable or access a single element of it.

A possible solution might be the following:

Delete the definition of the range i

At the end of the solve block use

Solution(i):=Find(c,y)

below the solve block define your range i:=0..11 and use

Out[i:=Solution(i)

This should do the job. "Out[i" means you use variable "Out" with vector index "i"

Oct 12, 2017
03:28 PM

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

Oct 12, 2017
03:28 PM

May be so

Oct 12, 2017
04:56 PM

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

Oct 12, 2017
04:56 PM

Hi Val!

I guess that turning the solve block into a function of i is exactly what I sugested, isn't it??

With the exection that you did not assign the result to a variable, as demanded.

In fact with your approach you have the same problem as Boyd experienced - you can't assign Out(i) to a variabe because the result still is not a true nested vector.

Only way without changing too much seems to be to write something like FinalOut[i:=Out(i) as I sugested.

The better way in my opinion (requires a bit more changes) would be to turn the solve block into a function with six arguments (representing the values of the six array used) and so get rid of the index i altogether Then this function would be called vectorized with the six arrays as argument.

Here is a Pic of a simplified expamlple which hopefully clarifies what I am talking about:

Oct 13, 2017
02:25 AM

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

Oct 13, 2017
02:25 AM

Thanks for the input.

Unfortunately I'm having laptop issues so am unable to make adjustments until Monday.

I had already tried the vectorised version and as I recall it was taking forever to solve because my input vectors are going to be about 10000 elements long.

The other option (right hand) looks like it might work other than I would prefer two separate arrays (one for x and other for y) but I guess I can do that after?

Thanks again

Unfortunately I'm having laptop issues so am unable to make adjustments until Monday.

I had already tried the vectorised version and as I recall it was taking forever to solve because my input vectors are going to be about 10000 elements long.

The other option (right hand) looks like it might work other than I would prefer two separate arrays (one for x and other for y) but I guess I can do that after?

Thanks again

Oct 13, 2017
05:26 PM

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

Oct 13, 2017
05:26 PM

I had already tried the vectorised version and as I recall it was taking forever to solve because my input vectors are going to be about 10000 elements long.

We would have to see the sheet, but I would not expect that to be a problem - at least it wasn't with Mathcad 15 (I am not using Prime for anything serious).

The other option (right hand) looks like it might work other than I would prefer two separate arrays (one for x and other for y) but I guess I can do that after?

The right hand version IS the one with vectorization and the format of the output of both version is the same and its also the same as your try with the range.

To get separate vectors for x and y you could either split the Result after caling the solve block OR you could call the solveblock twice.

First call x_vector[i := Out(i)[0 or in the right hand version x-vector:=Out2(a,b,c,d)[0 (of course vectorzed) and the same for y_vector with index 1 instead of 0).

If the solve blocks takes long to calculate, the second option of course is not the preferred one.

You could then use x_vec[i:=FinalOut[i[0 and y_vec[i:=FinalOut[i[1 if you have the range i defined or otherwise you would write a small program with a for-loop which does the job.

Oct 14, 2017
02:26 AM

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

Oct 14, 2017
02:26 AM

Thanks, yes sorry of course I meant 'left' in last post!

I'll have a go on Monday but it's looking promising.

Perhaps this is opening a can of worms and I'm sure there are other posts on it but for this type of use in particular what are the reasons you would use 15 over prime? I am just figuring out whether to switch, this was my first use of prime..

I'll have a go on Monday but it's looking promising.

Perhaps this is opening a can of worms and I'm sure there are other posts on it but for this type of use in particular what are the reasons you would use 15 over prime? I am just figuring out whether to switch, this was my first use of prime..

Oct 14, 2017
05:09 AM

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

Oct 14, 2017
05:09 AM

Yes, there are a lot of posts here about Prime vs- Mathac 15.

In short, Prime simply is much less capable compared to Mathcad. They have written Prime from scratch beginning some long years ago and until now were not able to catch up with Mathcad or (as it should be) outdo it. There are a few improvements in Prime over Mathcad, but the missing features and disadvantages are overwhelming.

After years of waiting for Prime to get mature many long time users of Mathcad have given up. It looks that in contrary to what PTC is promising they have no plan to improve Prime the wy it would be necessary. They seem to have other plans (like integrating Prime as a nice calculator in Creo).

So its looks to me and other users that Mathcad and Prime are dead ends and some of us have already left and some are on the way to look for other tools we could do our work with.

Switching to Mathcad sure wil make no sense for you as you are just trying if Mathcad or Prime are suitable tools for what you are doing. PTC support for Mathcad will end sooner or later and Prime, as I see it, will not improve significantly. So if Prime does the job for you, stay with it as it is, but don't expect it to get much more capable in the future.

Oct 14, 2017
05:39 AM

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

Oct 14, 2017
05:39 AM

Concerning speed I tested my simple example with vectors with 10^4 and 10^5 elements and vectorization evry time outperforms the other version:

BTW, heres a way to separate the x and y values