Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I thought I was making an innocuous change in a program, but it causes the For loop (or maybe the Solve block call) to fail. I haven't been able to figure out what the problem is. Worksheet is attached - program is shown at the bottom. Thanks in advance for any help.
Solved! Go to Solution.
And finally a version which also gets rid of the initial extra call to FuncTry in front of the loop. Instead of "augment" the column selector is now used to create the matrix "Out".
As you can see, I also rename "tauGuess" and "phiGuess" to just "tau" and "phi", but thats only cosmetics (but it makes the program look even smaller 😉
Worksheet saved in MC11 format attached
You are talking about the difference in behaviour between function "Solve2" and "Solve3" and the solve block "FuncTry" failing when called in "Solve3" ??
I guess that this solve block and the functions used therein assume that S is a scalar, right? (I have not digged in the details so far)
But in "Solve3" S is turned into a vector of values and this seems to throws the error.
Can it be that you inadvertently used the name "S" for two different things in your program?
Furthermore, you have ORIGIN=0 but you start the vectors S, x, v, Out and others with index 1. It looks to me that most of this vectors are not necessary to be vectors as you don't use the previous value in the next iteration.
Hi John,
@Werner_E has sharp eyes.
Here is a corrected version, with the corrections marked.
Success!
Luc
@LucMeekes changed the variable name of the vector S in your program to Ss to avoid the aforementioned conflict with the function argument S.
Here is a streamlined version of your program which gets completely rid of this variable Ss (also of v) and also avoids the creation of those unnecessary vectors (as outlined in my first reply.
Its also not necessary to collect all those previous "Outs" in a vector as every "Out" contains the values of the "Outs" before with just one column added.
IMHO this "vectorless" version looks a bit more cleaner 😉
And here is another modification which also gets rid of the local variable "R":
And finally a version which also gets rid of the initial extra call to FuncTry in front of the loop. Instead of "augment" the column selector is now used to create the matrix "Out".
As you can see, I also rename "tauGuess" and "phiGuess" to just "tau" and "phi", but thats only cosmetics (but it makes the program look even smaller 😉
Worksheet saved in MC11 format attached
Thanks. Your first message made me realize what the problem was. But thanks for cleaning and streamlining my program. As you probably know by now, despite using MC for many years, I am still a utilitarian programmer!