Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
In attempting to get the final function in the worksheet (under the heading "Lay Out PSO Algorithm and Find Best Results) to work, I am running into some problems. It will take some looking into, certainly, but Mathcad is saying that I'm not giving it scalar elements for the function "StressPenalty." If anyone could help me figure out why this is the case, I'd appreciate it (this code closely follows one that I know to work properly. It should work as it is).
Solved! Go to Solution.
Just a few "maybe's":
Using 1. and 2. and providing a range variable for plotting I get
WE
Right click here
and change from "Square Matrix Determinant" to "Absolute Value".
Now we get an index out of range error a line above because sigma.N only hase 8 rows and not 10.
Werner
Thank you. I got past all of that, but now it's telling me I'm not providing a vector just a couple of lines below the previous issue. I am on the verge of being done with this code, as this is basically the last function, but it's just giving me fits.
In the LocalBest function you define indx as the first value in the vector returned by match, so it's a scalar. In the next line you call index with a vector subscript of 2.
If you get rid of the 2 then you get another error because you pass phi to LocalBest, but after the first iteration phi is a matrix, not a vector. Pass column kk of phi to LocalBest and the program calculates. I can't say whether it gives the correct results though.
The error occurs here:
match() returns a vector, in your case containing just a single value (1), a 1x1 matrix.
"indx" is assigned the first element of this "vector" which is just a regular integer - with your data its the number 1.
But in the next line "indx" is treated as vector (which it isn't) and the (none existing) second element of this vector is addressed.
BTW, did you know that you can right click an erroneous expression and then select "Trace Error" to see where the error stems from?
WE
Just a few "maybe's":
Using 1. and 2. and providing a range variable for plotting I get
WE
Thank you! I realize now that it should've been in the otherwise loop. Gosh what a simple fix. I did know about Trace Error but usually don't find it to work too consistently. Would have helped in this case.