Way to reduce expression to it's value?

Way to reduce expression to it's value? - Сообщения

#1 Опубликовано: 30.01.2022 14:25:24
mecheng234

mecheng234

0 сообщений из 2 понравились пользователям.

Группа: User

Hi,

I'm having an issue with exporting a result of an equation with the Excel I/O Plugin. In my export matrix I have some values that are defined right before, i.e. L_C=1. Others are results of rather long equations, and they're not being exported. If I change the corresponding value in my export matrix to just the result, say 0,4441, it works fine but I need this to happen automatically. Is there a way to turn the result of an equation into just a number, basically rounding to a specific number of digits and making SMath forget where it came from?

I tried XLSX Import/Export but it's even worse, it exports the result as the whole equation and it doesn't work while the spreadsheet is opened, which I really like about Excel I/O.

Thanks in advance!
#2 Опубликовано: 30.01.2022 19:42:02
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Hi. The know way to "Way to reduce expression to it's value? " is using eval. Before exporting the data in M to excel, you can ensure that all are numeric and/or string values using 'M:=eval(M)'

Also, you can check taht all are defined values if 'M=' isn't red. If M is

If M is very large, you can check that all values of M are numeric by also evaluating 'max(M)'. If it does not give an error, it is because all the values of M are defined and reals.

That solve the issue?

Best regards.
Alvaro.
1 пользователям понравился этот пост
sergio 21.02.2022 11:38:00
#3 Опубликовано: 30.01.2022 20:04:58
mecheng234

mecheng234

0 сообщений из 2 понравились пользователям.

Группа: User

Wrote

Hi. The know way to "Way to reduce expression to it's value? " is using eval. Before exporting the data in M to excel, you can ensure that all are numeric and/or string values using 'M:=eval(M)'

Also, you can check taht all are defined values if 'M=' isn't red. If M is

If M is very large, you can check that all values of M are numeric by also evaluating 'max(M)'. If it does not give an error, it is because all the values of M are defined and reals.

That solve the issue?

Best regards.
Alvaro.



'M:=eval(M)' doesn't change anything and for 'max(M)' I'm getting "Units don't match", in M there is one value without unit, one angle, three values with unit N/N so no unit and another value without unit. Only the first value gets exported. I don't know if uploading my document would help, it's referring to another one with the include plugin and getting values from it and they're both not short.

#4 Опубликовано: 30.01.2022 22:06:58
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote


'M:=eval(M)' doesn't change anything and for 'max(M)' I'm getting "Units don't match"



If the values to be exported cannot be evaluated numerically in SMath, what value do you expect Excel to receive? That is, I think you have to identify why you cannot get the maximum of the matrix in SMath and then export its real and well-defined values to Excel.

Although I believe that the plugin can export things that are not evaluated in SMath, what Excel receives is usually well-defined numbers, real numbers without a complex part, without units, and in any case, strings. To ensure that an array is "well defined" in SMath for export to Excel, the test of requesting its maximum discards elements with errors, unevaluated, complex numbers and strings.

To see which values cause problems you can evaluate the array symbolically in SMath, since some cases, such as unit errors, can be inspected that way.

Best regards.
Alvaro.
#5 Опубликовано: 21.02.2022 09:07:31
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

It would make easier for us to help if you attach a worksheet.

It doesn't have to be the whole worksheet if you are able to reproduce the issue in a small independent block of code.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений