Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

mukushla

  • 2 years ago

how to write and call a simple function in matlab?

  • This Question is Closed
  1. ADGENIUS
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Syntex: function [y1,...,yN] = myfun(x1,...,xM)example Description: function [y1,...,yN] = myfun(x1,...,xM) declares a function named myfun that accepts inputs x1,...,xM and returns outputs y1,...,yN. This declaration statement must be the first executable line of the function. Save the function code in a text file with a .m extension. The name of the file should match the name of the first function in the file. Valid function names begin with an alphabetic character, and can contain letters, numbers, or underscores. Example: Define a function in a file named average.m that accepts an input vector, calculates the average of the values, and returns a single result. function y = average(x) if ~isvector(x) error('Input must be a vector') end y = sum(x)/length(x); Call the function from the command line. z = 1:99; average(z) ans = 50 for more detail visit: http://www.mathworks.com/help/matlab/ref/function.html#btexm3w

  2. mukushla
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thank u very much :)

  3. Not the answer you are looking for?
    Search for more explanations.

    Search OpenStudy
    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.