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.
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.
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.
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
below the solve block define your range i:=0..11 and use
This should do the job. "Out[i" means you use variable "Out" with vector index "i"
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:
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.
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.
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