# Changes

,  12:57, 17 February 2017
rework the evaluate-at-double example
Line 4: Line 4:
=== Demos and usage examples ===

=== Demos and usage examples ===
+
+
* ''' I'm trying to substitute a double value into an expression.  How can I avoid getting "warning: Using rat() heuristics for double-precision input (is this what you wanted?)"
+
+
In general, you should be very careful when converting floating point ("doubles") to symbolic variables, that's why the warning is bothering you.
+
+
<source lang="octave">
+
+
## Demo of how to use a number (which was calculated in an octave
+
## variable) in a symbolic calculation, without getting a warning.
+
+
## use octave to calculate some number:
+
a = pi/2
+
+
## now do some work with the symbolic pkg
+
syms x
+
f = x * cos (x)
+
df = diff (f)
+
+
## Now we want to evaluate df at a:
+
+
# subs (df, x, a)    # this gives the "rats" warning (and gives a symbolic answer)
+
+
+
+
dfh = function_handle (df)
+
+
dfh (a)
+
+
## And you can evaluate dfh at an array of "double" values:
+
+
dfh ([1.23 42.42 pi/2])
+
+
</source>
+

* '''Demo of Anonymous function to symbolic function and back to anonymous function and then the use of the interval pkg.'''

* '''Demo of Anonymous function to symbolic function and back to anonymous function and then the use of the interval pkg.'''
Line 99: Line 133:
grid minor on

grid minor on
−
</source>
−
−
* '''Demo of how to suppress a warning about converting from floating point numbers to symbolic numbers.
−
−
<source lang="octave">
−
−
## Demo of how to use a number (which was calculated in an octave
−
## variable) in a symbolic calculation, without getting a warning.
−
−
## use octave to calculate some number:
−
a=pi/2
−
−
## now do some work with the symbolic pkg
−
syms x
−
f = x * cos(x)
−
df = diff(f)
−
−
## Next get the number into a symbolic variable
−
## convert to string first
−
aa=mat2str(a)
−
## and now to a symbolic variable.
−
ww=sym(aa)
−
## and now use it
−
vpa(subs(df, x, ww), 28)
−

</source>

</source>
64

edits