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

  • Thread starter Thread starter satinysol
  • Start date Start date
  • Tags Tags
    Function Matlab
AI Thread Summary
To call functions in MATLAB using an m-file, simply use the function names as defined at the top of each file. A main m-file can be created to prompt user input and call other functions. For example, to use a function like peakfinder, you can call it with the appropriate input, such as [peakMag, peakloc] = peakfinder(smootherwavedata). This method allows you to retrieve the desired output values from your data. The user confirmed that the function call works successfully.
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. ^^
 

Similar threads

Replies
1
Views
2K
Replies
4
Views
1K
Replies
1
Views
2K
Replies
3
Views
1K
Replies
4
Views
5K
Replies
1
Views
3K
Back
Top