Thread Subject: Help needed wih simple diff function

Subject: Help needed wih simple diff function

From: A

Date: 29 Apr, 2008 14:23:04

Message: 1 of 1

Hi to all!

I really need some help with a m-file I'm working on. I know
some math but I'm a total noob with matlab.

I need to write an m-file that does the following operations
to a given function.
-given function = f
-given dot = x
-given spacing = dx

The function that would do all of the operations is named as
fun.

1. The fun function will calculate the derivative of any
given function f in any given dot x.

2. The fun will also calculate the differential of the given
function f in the given dot x, both a estimate and the
accurate value with the given spacing dx.

3. This is tough one. The function fun will calculate the
equation of the tangent for the given function f with the
given dot x.

Here's what I've done so far:

function out = fun(f,x,dx)

out = diff(f,x); %The derivative of the function.

out = (diff(f,x)*dx %The estimated value of the differential.



Problems I have with the m-file:
-How is i possible to get multiple out's from one m-file?
-How can I substitute the x with the given value of the x?

All tips are very welcome. Cheers!

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com