1 страниц (4 вхождений)
error when creating a matrix from a function - resulting matrix only contains the last values of the nested "for' loops - Сообщения
#1 Опубликовано: 03.07.2020 18:18:32
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?
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?
#2 Опубликовано: 03.07.2020 20:25:23
No document = No monkey see no monkey do
#3 Опубликовано: 03.07.2020 21:25:43
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.
I had previously tried using clear statements in the matrix creation function with no success.
#4 Опубликовано: 04.07.2020 08:22:25
1 пользователям понравился этот пост
Harvey Hensley 04.07.2020 18:38:00
1 страниц (4 вхождений)
-
Новые сообщения
-
Нет новых сообщений