Editing Symbolic package
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
The {{Forge|symbolic|symbolic package}} is part of the | The {{Forge|symbolic|symbolic package}} is part of the octave-forge project. | ||
[[Category:Octave Forge]] | [[Category:Octave-Forge]] | ||
=== Demos and usage examples === | === Demos and usage examples === | ||
Line 43: | Line 43: | ||
</source> | </source> | ||
<source lang="octave"> | <source lang="octave"> | ||
## The following code will produce the same vector field plot as Figure 1.14 from Example 1.6 (pg. 39) from A Student's Guide to Maxwell's Equations by Dr. Daniel Fleisch. | ##Demo of how to graph symbolic functions (by converting SYMBOLIC functions into ANONYMOUS functions) | ||
##The following code will produce the same vector field plot as Figure 1.14 from Example 1.6 (pg. 39) from A Student's Guide to Maxwell's Equations by Dr. Daniel Fleisch. | |||
## Make sure symbolic package is loaded and symbolic variables declared. | ##Make sure symbolic package is loaded and symbolic variables declared. | ||
pkg load symbolic | pkg load symbolic; | ||
syms x y | syms x y | ||
## Write a Vector Field Equation in terms of symbolic variables | ##Write a Vector Field Equation in terms of symbolic variables | ||
vector = [sin(pi .* y ./2 ); -sin(pi .* x ./2 )]; | |||
## Vector components are converted from | ##Vector components are converted from symoblic into anonymous form which allows them to be graphed | ||
## The "'vars', [x y]" syntax | ##The '1' & '2', in vector(1) & vector(2) are indeces for the vector. | ||
iComponent = function_handle ( | ##The " 'vars', [x y]" syntax tells function_handle that each component is a function of both 'x' & 'y' | ||
jComponent = function_handle ( | iComponent = function_handle (vector(1), 'vars', [x y]); | ||
jComponent = function_handle (vector(2), 'vars', [x y]); | |||
## | ##Setting the Grid up to graph all axes for all variables from -.5 to .5, with spacings .05 apart. | ||
[X,Y] = meshgrid ([- | [X,Y] = meshgrid([-.5:.05:.5]); | ||
##Draw the Vector Field! | |||
figure | figure | ||
quiver (X, Y, iComponent (X, Y), jComponent (X,Y)) | quiver(X,Y,iComponent(X,Y),jComponent(X,Y)) | ||
</source> | </source> | ||
Line 160: | Line 159: | ||
## | ## | ||
syms y(x) | syms y(x) | ||
de =diff(y, 3 ) +sqrt(2)*diff(y,2) + diff(y) == 0; | |||
de =diff(y, 3 ) + | |||
f = dsolve(de, y(0) == 0, diff(y,1)(0) == 0 , diff(y,2)(0) == 1) | f = dsolve(de, y(0) == 0, diff(y,1)(0) == 0 , diff(y,2)(0) == 1) | ||
ff=function_handle(rhs(f)) | ff=function_handle(rhs(f)) |