I have one file with the following code:
function fx=ff(x)
fx=x;
I have another file with the following code:
function g = Lapl
The error message here is about as self-explanatory as it gets. You aren't defining a variable called x
, so when you reference it on the first line of your function, MATLAB doesn't know what to use. You need to either define it in the function before referencing it, pass it into the function, or define it somewhere further up the stack so that it will be accessible when you call LaplaceTransform.
Since you're trying to numerically integrate with respect to x
, I'm guessing you want x
to take on values evenly spaced on your domain [0,1]. You could accomplish this using e.g.
x = linspace(a,b,N);
EDIT: There are a couple of other problems here: first, when you define g
, you need to use .*
instead of *
to multiply the elements in the arrays (by default MATLAB interprets multiplication as matrix multiplication). Second, your calls g(a)
and g(b)
are treating g
as a function instead of as an array of function values. This is something that takes some getting used to in MATLAB; instead of g(a)
, you really want the first element of the vector g
, which is given by g(1)
. Similarly, instead of g(b)
, you want the last element of g
, which is given by g(length(g))
or g(end)
. If this doesn't make sense, I'd suggest looking at a basic MATLAB tutorial to get a handle on how vectors and functions are used.