<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168693</link>
    <title>MATLAB Central Newsreader - A few questions about using matlab</title>
    <description>Feed for thread: A few questions about using matlab</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 04 May 2008 11:22:03 -0400</pubDate>
      <title>A few questions about using matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168693#430151</link>
      <author>A </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I'm trying to write and m-file and I'm having a few problems.&lt;br&gt;
&lt;br&gt;
1. How do I use a given value of x in functions?&lt;br&gt;
&lt;br&gt;
Example, my function is fun(f,x). I input fun(ln(x),2) and&lt;br&gt;
it only gives me the derivative with the x, 1/x. I want the&lt;br&gt;
output to give me the derivative with the 2, 0.5.&lt;br&gt;
&lt;br&gt;
This is how it looks like now:&lt;br&gt;
&lt;br&gt;
Function out = fun(f,x)&lt;br&gt;
&lt;br&gt;
out = diff(f,x);&lt;br&gt;
&lt;br&gt;
2. Do any of you have any idea what function would calculate&lt;br&gt;
the equation of the tangent for the given function f with a&lt;br&gt;
given dot x?&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 04 May 2008 13:20:36 -0400</pubDate>
      <title>Re: A few questions about using matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168693#430162</link>
      <author>dpb</author>
      <description>A wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm trying to write and m-file and I'm having a few problems.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1. How do I use a given value of x in functions?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Example, my function is fun(f,x). I input fun(ln(x),2) and&lt;br&gt;
&amp;gt; it only gives me the derivative with the x, 1/x. I want the&lt;br&gt;
&amp;gt; output to give me the derivative with the 2, 0.5.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is how it looks like now:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Function out = fun(f,x)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; out = diff(f,x);&lt;br&gt;
&lt;br&gt;
You would need optional symbolic toolbox to manipulate algebraic &lt;br&gt;
expressions and derivatives thereof other than numerically.&lt;br&gt;
&lt;br&gt;
diff() is a pointwise 1st-order difference approximation to the &lt;br&gt;
derivative of a numerical vector, _not_ a symbolic differentiator, sorry.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; 2. Do any of you have any idea what function would calculate&lt;br&gt;
&amp;gt; the equation of the tangent for the given function f with a&lt;br&gt;
&amp;gt; given dot x?&lt;br&gt;
&lt;br&gt;
In the general case would be symbolic again (iiu the question)...&lt;br&gt;
&lt;br&gt;
--&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Sun, 04 May 2008 16:29:03 -0400</pubDate>
      <title>Re: A few questions about using matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168693#430175</link>
      <author>carlos lopez</author>
      <description>Hello amutka@welho.com:&lt;br&gt;
Aside of the answer by dbp, you might want to consider using&lt;br&gt;
a free toolbox named ADMAT. It allows to evaluate&lt;br&gt;
numerically (not analytically) any function derivative. It&lt;br&gt;
also deals with vector-valued functions, which leads to&lt;br&gt;
Jacobians.&lt;br&gt;
&lt;br&gt;
To illustrate the behavior I might use this script:&lt;br&gt;
&amp;gt;&amp;gt; x=deriv(17,1)  &lt;br&gt;
val =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;br&gt;
deriv =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
&amp;gt;&amp;gt; y=x.*x+3*log(x)&lt;br&gt;
val =&lt;br&gt;
&amp;nbsp;&amp;nbsp;297.4996&lt;br&gt;
deriv =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;34.1765&lt;br&gt;
&lt;br&gt;
The first statement defines the variable x as the one which&lt;br&gt;
against the derivatives should be performed. It is&lt;br&gt;
initialized with 17, and a second field is specified as "1". &lt;br&gt;
The second statement defines the formula to be analyzed,&lt;br&gt;
which value should be stored in variable "y". &lt;br&gt;
Notice that Matlab reports that y has two fields; y.val&lt;br&gt;
which is the value you expect to get (17*17+3*log(17)) and&lt;br&gt;
the interesting one: y.deriv, which is numerically equal to&lt;br&gt;
2*17+3/17 (i.e. the exact formula for the derivative.&lt;br&gt;
The technology behind this miracle is "operator&lt;br&gt;
overloading", and fortunately for use we need not to know&lt;br&gt;
anything about it.&lt;br&gt;
&lt;br&gt;
To illustrate something else, if you want to use your&lt;br&gt;
example you should modify it a bit:&lt;br&gt;
Function out = fun(f,x)&lt;br&gt;
x=deriv(x,ones(size(x)));&lt;br&gt;
dummy = feval(f,x);&lt;br&gt;
out=dummy.val;&lt;br&gt;
&lt;br&gt;
If you want to test this workaround, I can provide a copy of&lt;br&gt;
the ADMAT toolbox. Just ask me off the list.&lt;br&gt;
Regards&lt;br&gt;
Carlos&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 06 May 2008 13:41:20 -0400</pubDate>
      <title>Re: A few questions about using matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168693#430565</link>
      <author>A </author>
      <description>"carlos lopez" &amp;lt;clv2clv_00000000_@adinet.com.uy&amp;gt; wrote in&lt;br&gt;
message &amp;lt;fvko8f$kam$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; To illustrate something else, if you want to use your&lt;br&gt;
&amp;gt; example you should modify it a bit:&lt;br&gt;
&amp;gt; Function out = fun(f,x)&lt;br&gt;
&amp;gt; x=deriv(x,ones(size(x)));&lt;br&gt;
&amp;gt; dummy = feval(f,x);&lt;br&gt;
&amp;gt; out=dummy.val;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If you want to test this workaround, I can provide a copy of&lt;br&gt;
&amp;gt; the ADMAT toolbox. Just ask me off the list.&lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; Carlos&lt;br&gt;
&lt;br&gt;
I don't have matlab at home so I wasn't able to try this&lt;br&gt;
example out until today.&lt;br&gt;
&lt;br&gt;
It gave me following error:&lt;br&gt;
"??? Undefined function or variable 'x'."&lt;br&gt;
&lt;br&gt;
I entered the function as &amp;gt;&amp;gt;fun(log(x),2)&lt;br&gt;
&lt;br&gt;
.A&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 06 May 2008 15:41:03 -0400</pubDate>
      <title>Re: A few questions about using matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/168693#430594</link>
      <author>carlos lopez</author>
      <description>&amp;gt; I don't have matlab at home so I wasn't able to try this&lt;br&gt;
&amp;gt; example out until today.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It gave me following error:&lt;br&gt;
&amp;gt; "??? Undefined function or variable 'x'."&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I entered the function as &amp;gt;&amp;gt;fun(log(x),2)&lt;br&gt;
Apparently you did not defined anything named as "x". What&lt;br&gt;
do you expect from a statement like "fun(log(x),2)"?&lt;br&gt;
BTW, are you trying to use my solution, or the&lt;br&gt;
symbolic-based one? If you want to try mine you need to&lt;br&gt;
install the toolbox before!&lt;br&gt;
Regards&lt;br&gt;
Carlos&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
