Editing Symbolic package

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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 [[Octave Forge]] project.
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 41: Line 41:
ans =
ans =
   -0.82502  4.20248  -1.57080
   -0.82502  4.20248  -1.57080
</source>
* '''Demo of how to graph symbolic functions (by converting SYMBOLIC functions into ANONYMOUS functions)'''
<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.
## Make sure symbolic package is loaded and symbolic variables declared.
pkg load symbolic
syms x y
## Write a Vector Field Equation in terms of symbolic variables
vectorfield = [sin(pi*y/2); -sin(pi*x/2)];
## 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'
iComponent = function_handle (vectorfield(1), 'vars', [x y]);
jComponent = function_handle (vectorfield(2), 'vars', [x y]);
## Setup a 2D grid
[X,Y] = meshgrid ([-0.5:0.05:0.5]);
figure
quiver (X, Y, iComponent (X, Y), jComponent (X,Y))


</source>
</source>
Line 160: Line 132:
  ##
  ##
  syms y(x)  
  syms y(x)  
sqrt2=sym(1.41421);
  de =diff(y, 3 ) +sqrt(2)*diff(y,2) + diff(y) == 0;
  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))
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: