1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Question on Matlab

  1. Jan 7, 2008 #1
    I am new to Matlab and got a question to ask.

    I have created a .m file which plots a cosine graph.
    For simplicity, say

    Then this will create a plot with cos(2piT) with domain of 0~T.

    I will like to export this to other .m file so the file can read this graph and calculate the frequency of graph.
    But I'm stuck as how I can export this graphical data to other .m file.

    Because if I just lookup data on x, it will just give out an array of 1000 values and not knowing its domain(time), I can not calculate the frequency.

    Hope this makes sense.

    Will appreciate your helps!
  2. jcsd
  3. Jan 8, 2008 #2


    User Avatar

    a couple of points:

    Firstly the best way to do this is to write the function so that it returns time & x.

    Put this at the very top of your m file
    Code (Text):

    function [x,time]=mygenfunc(T)
    Save the file as mygenfunc.m

    Then call the function from somewhere using
    Code (Text):

    for example.

    If you are dead set on using the graph then the following code may be of use:
    Code (Text):

    Last edited: Jan 8, 2008
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Question on Matlab
  1. MATLAB questions (Replies: 0)

  2. MATLAB question (Replies: 2)

  3. MATLAB question (Replies: 1)

  4. Matlab question (Replies: 2)

  5. Matlab question (Replies: 10)