1,848
edits
WARDEVIL UFO (talk | contribs) |
m (Rename "Octave-Forge" to "Octave Forge" (https://lists.gnu.org/archive/html/octave-maintainers/2018-08/msg00138.html).) |
||
(2 intermediate revisions by 2 users not shown) | |||
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 | [[Category:Octave Forge]] | ||
=== Demos and usage examples === | === Demos and usage examples === | ||
Line 50: | Line 50: | ||
<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. | ## 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 | ||
vectorfield = [sin(pi*y/2); -sin(pi*x/2)]; | |||
##Vector components are converted from | ## Vector components are converted from symbolic into "anonymous functions" which allows them to be graphed. | ||
## The "'vars', [x y]" syntax ensures each component is a function of both 'x' & 'y' | |||
##The " 'vars', [x y]" syntax | iComponent = function_handle (vectorfield(1), 'vars', [x y]); | ||
iComponent = function_handle ( | jComponent = function_handle (vectorfield(2), 'vars', [x y]); | ||
jComponent = function_handle ( | |||
## | ## Setup a 2D grid | ||
[X,Y] = meshgrid([-.5:.05:.5]); | [X,Y] = meshgrid ([-0.5:0.05:0.5]); | ||
figure | figure | ||
quiver(X,Y,iComponent(X,Y),jComponent(X,Y)) | quiver (X, Y, iComponent (X, Y), jComponent (X,Y)) | ||
</source> | </source> | ||
Line 162: | Line 160: | ||
## | ## | ||
syms y(x) | syms y(x) | ||
de =diff(y, 3 ) + | sqrt2=sym(1.41421); | ||
de =diff(y, 3 ) +sqrt2*diff(y,2) + diff(y) == 0; | |||
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)) |