SMath Studio Forum
»
SMath Studio
»
Questions
»
error when creating a matrix from a function
Rank: Member Groups: Registered
Joined: 28/05/2020(UTC) Posts: 18 Location: Bartlesville, OK Was thanked: 4 time(s) in 2 post(s)
|
I have a function called "rfun(x,y) that calculates a dimensionless reaction rate. The function works fine when calculating a single value, but when it appears in a program function used to create a matrix of rates for x and y vector inputs, it doesn't work properly. All elements of the resulting matrix contain the same value which corresponds to the last value calculated. See below. I found a workaround as shown in the next image. All of the elements produced by these two functions are correct. Can anyone explain why the first method doesn't work? If I try this method with simpler functions, it works fine. The rfun function involves some use of the Prode Physical properties which may be a cause. However, since the rfun function works fine for a single result, I don't understand why it doesn't work here. Also, the rfun function doesn't work in Maxima Draw3d either. Also, is there a more elegant workaround that could be done in just one program function?
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
No document = No monkey see no monkey do
|
|
|
|
Rank: Member Groups: Registered
Joined: 28/05/2020(UTC) Posts: 18 Location: Bartlesville, OK Was thanked: 4 time(s) in 2 post(s)
|
I found a solution. When I create the rfun function, I do it with a program. The first line of the program is a Clear() statement that clears the output of the rate function. The second line is the result = math expression, and the last line is the result variable for the output.
I had previously tried using clear statements in the matrix creation function with no success.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: Harvey Hensley I had previously tried using clear statements in the matrix creation function with no success. When re-using matrix/vector in program, set [M, V]:=0
|
1 user thanked Jean Giraud for this useful post.
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
error when creating a matrix from a function
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.