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

  • Thread starter Thread starter satinysol
  • Start date Start date
  • Tags Tags
    Function Matlab
Click For Summary

Discussion Overview

The discussion revolves around how to call functions in MATLAB using an m-file. Participants are exploring the process of creating a main m-file that interacts with user input and calls other functions defined in separate m-files.

Discussion Character

  • Technical explanation, Homework-related

Main Points Raised

  • One participant describes the need to create an m-file that prompts the user for two values and calls a series of functions to return an answer.
  • Another participant suggests that functions can be called by their names as defined in the m-file.
  • A further participant provides an example of calling a specific function, peakfinder, and inquires whether it is correct to use it with their data.
  • Responses indicate that the approach seems reasonable, and one participant confirms that it works.

Areas of Agreement / Disagreement

Participants generally agree on the method of calling functions by their names, and there appears to be consensus on the specific example provided, though no formal resolution of any issues is detailed.

Contextual Notes

No specific limitations or unresolved mathematical steps are noted in the discussion.

Who May Find This Useful

Individuals learning MATLAB, particularly those working on homework or projects involving function calls and m-files.

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 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K