help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help Plotting Symbolic Vector Fields with Substitutions


From: WARDEVIL_UFO
Subject: Re: Help Plotting Symbolic Vector Fields with Substitutions
Date: Fri, 21 Apr 2017 00:38:06 -0700 (PDT)

I have had trouble posting on Nabble's Octave Forum the past 2 days.  I had
this response written Wednesday, but haven't had any luck until now.


Colin Macdonald-2 wrote
> I filed a bug to do that: https://github.com/cbm755/octsympy/issues/779. 
>   Since this is fresh on your mind, perhaps you could suggest a short 
> paragraph for "help subs" perhaps with a simple example?
> 
> Another option: we could overload @sym/quiver3.
> 
> thanks,
> Colin

I am new to Matlab/Octave.  I don't know what overloading is.  Also, to date
I have never successfully called subs in Octave.  The code you guys saw was
my first attempt to do just that.  I know next to nothing about the approved
applications for subs.  In the above case I attempted copying code I saw
from a MatLab help example.  As far as a simple example, I would be honored
to help!!!!

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.  Beware that this code is somewhat custom tailored to
this particular example.
________________________________________________________________________________________________
pkg load symbolic;

syms x y

vector = [sin(pi*y ./ 2); -sin(pi*x ./ 2)];

iComponent = function_handle(vector(1,1));
jComponent = function_handle(vector(2,1));

[X,Y] = meshgrid([-.5:.05:.5]);

figure

quiver(X,Y,iComponent(Y),jComponent(X))
________________________________________________________________________________________________

After I tackled this example, I went on to write a routine that will take in
a Vector Field in cylindrical coordinates and plot the field (my previous
post), and another routine that does the same for spherical coordinates. 
For reasons I do not yet understand, my spherical and cylindrical routines
seem to be *immune to the following  2 quirks* that happen when I attempt to
extend the above simpler example to certain cases.
(1) Using a floating point numbers inside my vector
(2)  Calling quiver like" quiver(X,Y,iComponent(X,Y),jComponent(X,Y)) when
iComponent does not include variable 'x' somewhere, and jComponent does not
include variable 'y' somewhere.

The spherical and cylindrical routines are more flexible in their current
form.  Perhaps if I mimic some of the steps done in my cylindrical and
spherical examples for the pure cartesian case, the same flexibility just
*might*   be extended to this example.  However, doing so might convolute
the basic illustration of how to use function_handle() to convert symbolic
expressions from within a matrix to a form usable by quiver or quiver3.

I will reply later on the Octave Online issue in another post.




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Help-Plotting-Symbolic-Vector-Fields-with-Substitutions-tp4682904p4682959.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]