Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The error message here is about as self-explanatory as it gets. You aren't defining a variable called <code>x</code>, 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.</p> <p>Since you're trying to numerically integrate with respect to <code>x</code>, I'm guessing you want <code>x</code> to take on values evenly spaced on your domain [0,1]. You could accomplish this using e.g.</p> <pre><code>x = linspace(a,b,N); </code></pre> <p>EDIT: There are a couple of other problems here: first, when you define <code>g</code>, you need to use <code>.*</code> instead of <code>*</code> to multiply the elements in the arrays (by default MATLAB interprets multiplication as matrix multiplication). Second, your calls <code>g(a)</code> and <code>g(b)</code> are treating <code>g</code> as a function instead of as an array of function values. This is something that takes some getting used to in MATLAB; instead of <code>g(a)</code>, you really want the first element of the <em>vector</em> <code>g</code>, which is given by <code>g(1)</code>. Similarly, instead of <code>g(b)</code>, you want the last element of <code>g</code>, which is given by <code>g(length(g))</code> or <code>g(end)</code>. 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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload