Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab ploting

  1. Jan 7, 2013 #1
    hello.can anyone help me to plot this function in matlab

    Q=quad(@(omeg)myfun(omeg,x,t),-20,20).im not sure if this is correct.my m file function goes like that
    function y= @myfun(omeg,x,t)

    thanks in advance
  2. jcsd
  3. Jan 9, 2013 #2


    User Avatar
    Gold Member


    There are a few problems with the syntax you posted if you are trying to plot the function. For starters, your m-file should look like this:

    function y = myfun(omeg,x,t)
    y = besselj(1,omeg.*x).*cos(omeg.*t).*omeg;


    The '@' symbol is used for function handles, and it tells MATLAB which letter is the variable. Now let's make two vectors that we can plot:

    x1 = -20:0.1:20;

    for i=1:1:max(size(x1))


    Since you have 3 inputs for the original function, we need to keep two constant and plot against the third. In this case, I let the x1 values represent omega, and I gave x and t a default value of 1. You could switch this around easily by changing where the x1(i) is in the loop.

    Attached Files:

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Matlab ploting Date
How to program this in Matlab Feb 28, 2018
Matlab Making a short test for self-adjointness Feb 23, 2018
Matlab Second Derivative Ploting Problem Feb 12, 2012
Ploting Graph - Matlab Apr 22, 2009
Matlab Second Derivative Ploting Problem Dec 5, 2004