<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://fweb.wallawalla.edu/class-wiki/index.php?action=history&amp;feed=atom&amp;title=Derivative_Operator_Picture_Code</id>
	<title>Derivative Operator Picture Code - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://fweb.wallawalla.edu/class-wiki/index.php?action=history&amp;feed=atom&amp;title=Derivative_Operator_Picture_Code"/>
	<link rel="alternate" type="text/html" href="https://fweb.wallawalla.edu/class-wiki/index.php?title=Derivative_Operator_Picture_Code&amp;action=history"/>
	<updated>2026-05-18T07:28:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://fweb.wallawalla.edu/class-wiki/index.php?title=Derivative_Operator_Picture_Code&amp;diff=8901&amp;oldid=prev</id>
		<title>John.hawkins: Main Content</title>
		<link rel="alternate" type="text/html" href="https://fweb.wallawalla.edu/class-wiki/index.php?title=Derivative_Operator_Picture_Code&amp;diff=8901&amp;oldid=prev"/>
		<updated>2010-02-05T06:19:08Z</updated>

		<summary type="html">&lt;p&gt;Main Content&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The figure in [[Derivative Matrix for a Function Vector]] was generated with the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
%                                                                           &lt;br /&gt;
&lt;br /&gt;
%  _-_,,       ,,                _-_-                   ,,                  &lt;br /&gt;
&lt;br /&gt;
% (  //        ||                  /,        _   ;      ||    &amp;#039;             &lt;br /&gt;
&lt;br /&gt;
%   _||   /&amp;#039;\\ ||/\\ \\/\\         || __    &amp;lt; \, \\/\/\ ||/\ \\ \\/\\  _-_, &lt;br /&gt;
&lt;br /&gt;
%   _||  || || || || || ||        ~||-  -   /-|| || | | ||_&amp;lt; || || || ||_.  &lt;br /&gt;
&lt;br /&gt;
%    ||  || || || || || ||         ||===|| (( || || | | || | || || ||  ~ || &lt;br /&gt;
&lt;br /&gt;
% -__-,  \\,/  \\ |/ \\ \\        ( \_, |   \/\\ \\/\\/ \\,\ \\ \\ \\ ,-_-  &lt;br /&gt;
&lt;br /&gt;
%                _/                     `                                   &lt;br /&gt;
&lt;br /&gt;
%  &lt;br /&gt;
&lt;br /&gt;
% John Hawkins&lt;br /&gt;
&lt;br /&gt;
% LNA&lt;br /&gt;
&lt;br /&gt;
% Derivative Matrix Example&lt;br /&gt;
&lt;br /&gt;
% 2 Feb 2010&lt;br /&gt;
&lt;br /&gt;
function DerivativeExample&lt;br /&gt;
&lt;br /&gt;
x=linspace(0,4*pi,500)&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
y=sin(x);&lt;br /&gt;
&lt;br /&gt;
dydx=cos(x);&lt;br /&gt;
&lt;br /&gt;
h.fig=figure(&amp;#039;color&amp;#039;,&amp;#039;w&amp;#039;,&amp;#039;units&amp;#039;,&amp;#039;normalized&amp;#039;,&amp;#039;position&amp;#039;,[.2 .2 .6 .6]);&lt;br /&gt;
&lt;br /&gt;
plot(x,y,&amp;#039;color&amp;#039;,[.8 .8 .8]);&lt;br /&gt;
&lt;br /&gt;
hold on;&lt;br /&gt;
&lt;br /&gt;
plot(x,dydx,&amp;#039;color&amp;#039;,[.8 .8 .8]);&lt;br /&gt;
&lt;br /&gt;
numStartPoints=10;&lt;br /&gt;
&lt;br /&gt;
x=linspace(0,4*pi,numStartPoints)&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
y=sin(x);&lt;br /&gt;
&lt;br /&gt;
dydx=DERIV(x,y);&lt;br /&gt;
&lt;br /&gt;
h.y=plot(x,y,&amp;#039;b.&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
h.construct=plot(0,0,&amp;#039;r&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
h.dydx=plot(0,0,&amp;#039;r.&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
legend([h.y,h.construct,h.dydx],&amp;#039;y&amp;#039;,&amp;#039;Construction Line&amp;#039;,&amp;#039;dy/dx&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
xlabel(&amp;#039;x&amp;#039;); ylabel(&amp;#039;y&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
axis equal;&lt;br /&gt;
&lt;br /&gt;
title(&amp;#039;Taking the Derivative of a Finite Function Vector for y=sin x&amp;#039;,...&lt;br /&gt;
&lt;br /&gt;
    &amp;#039;fontname&amp;#039;,&amp;#039;times&amp;#039;,&amp;#039;fontsize&amp;#039;,20);&lt;br /&gt;
&lt;br /&gt;
set([h.construct,h.dydx],&amp;#039;visible&amp;#039;,&amp;#039;off&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
fig = getframe(h.fig);&lt;br /&gt;
&lt;br /&gt;
[im,map] = rgb2ind(fig.cdata,256,&amp;#039;nodither&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
set(h.construct,&amp;#039;visible&amp;#039;,&amp;#039;on&amp;#039;,&amp;#039;xdata&amp;#039;,x([1,2]),&amp;#039;ydata&amp;#039;,y([1,2]));&lt;br /&gt;
&lt;br /&gt;
im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
set(h.dydx,&amp;#039;visible&amp;#039;,&amp;#039;on&amp;#039;,&amp;#039;xdata&amp;#039;,x(1),&amp;#039;ydata&amp;#039;,dydx(1));&lt;br /&gt;
&lt;br /&gt;
im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
for n=2:numStartPoints-1&lt;br /&gt;
&lt;br /&gt;
    set(h.construct,&amp;#039;xdata&amp;#039;,x([n-1,n+1]),&amp;#039;ydata&amp;#039;,y([n-1,n+1]));&lt;br /&gt;
&lt;br /&gt;
    im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
    set(h.dydx,&amp;#039;xdata&amp;#039;,x(1:n),&amp;#039;ydata&amp;#039;,dydx(1:n));&lt;br /&gt;
&lt;br /&gt;
    im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
set(h.construct,&amp;#039;xdata&amp;#039;,x([numStartPoints-1,numStartPoints]),...&lt;br /&gt;
&lt;br /&gt;
    &amp;#039;ydata&amp;#039;,y([numStartPoints-1,numStartPoints]));&lt;br /&gt;
&lt;br /&gt;
im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
set(h.dydx,&amp;#039;xdata&amp;#039;,x,&amp;#039;ydata&amp;#039;,dydx);&lt;br /&gt;
&lt;br /&gt;
im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
set(h.construct,&amp;#039;visible&amp;#039;,&amp;#039;off&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
for k=1:5&lt;br /&gt;
&lt;br /&gt;
    im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
for n=[15 20 30 50 100 200 500]&lt;br /&gt;
&lt;br /&gt;
    x=linspace(0,4*pi,n)&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
    y=sin(x);&lt;br /&gt;
&lt;br /&gt;
    dydx=DERIV(x,y);&lt;br /&gt;
&lt;br /&gt;
    set(h.y,&amp;#039;xdata&amp;#039;,x,&amp;#039;ydata&amp;#039;,y);&lt;br /&gt;
&lt;br /&gt;
    set(h.dydx,&amp;#039;xdata&amp;#039;,x,&amp;#039;ydata&amp;#039;,dydx);&lt;br /&gt;
&lt;br /&gt;
    im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
for k=1:5&lt;br /&gt;
&lt;br /&gt;
    im=CAPTUREFIG(im,map,h);&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
imwrite(im,map,&amp;#039;Derivative.gif&amp;#039;,&amp;#039;DelayTime&amp;#039;,.5,&amp;#039;LoopCount&amp;#039;,inf)&lt;br /&gt;
&lt;br /&gt;
function dydx=DERIV(x,y)&lt;br /&gt;
&lt;br /&gt;
num=numel(y);&lt;br /&gt;
&lt;br /&gt;
deltax=x(2)-x(1);&lt;br /&gt;
&lt;br /&gt;
operator=zeros(num);&lt;br /&gt;
&lt;br /&gt;
operator(1,1)=-2;&lt;br /&gt;
&lt;br /&gt;
operator(1,2)=2;&lt;br /&gt;
&lt;br /&gt;
for k=2:num-1&lt;br /&gt;
&lt;br /&gt;
    operator(k,k+1)=1;&lt;br /&gt;
&lt;br /&gt;
    operator(k,k-1)=-1;&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
operator(num,num-1)=-2;&lt;br /&gt;
&lt;br /&gt;
operator(num,num)=2;&lt;br /&gt;
&lt;br /&gt;
operator=operator/(2*deltax);&lt;br /&gt;
&lt;br /&gt;
dydx=operator*y;&lt;br /&gt;
&lt;br /&gt;
function im=CAPTUREFIG(im,map,h)&lt;br /&gt;
&lt;br /&gt;
fig = getframe(h.fig);&lt;br /&gt;
&lt;br /&gt;
im(:,:,1,size(im,4)+1) = rgb2ind(fig.cdata,map,&amp;#039;nodither&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>John.hawkins</name></author>
	</entry>
</feed>