How do I call functions in MATLAB using an m-file?

  • Thread starter Thread starter satinysol
  • Start date Start date
  • Tags Tags
    Function Matlab
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 3K views
satinysol
Messages
14
Reaction score
0
I have to make an m-file that asks the user to input two values.

Then it performs a series of functions and returns an answer.

I have made the functions (each in their own m-file)

But I don't understand how you call functions using an m-file. I have to have one main m-file which calls all the functions so it can give an answer to the user...

Please help me ,thx
 
Physics news on Phys.org
You just call the functions by their names as defined on the top line of the file. Post an example of one of your functions.
 
Joffan said:
You just call the functions by their names as defined on the top line of the file. Post an example of one of your functions.

I want to call this function function varargout = peakfinder(x0, sel, thresh, extrema) which need me to input x0.

the command for running this function is [peakMag,peakloc]=peakfinder(x0) which can let me get the values of peakMag and peakloc.

then i wrote my own m.file and need to use this function to get peakMag and peakloc of my data , can i just use [peakMag,peakloc]=peakfinder(smootherwavedata); to get the values ?
 
sounds reasonable. What's the issue?
 
Joffan said:
sounds reasonable. What's the issue?

It works now. ^^