How to create a custom function?
Show older comments
If you are given an equation and told to write a function that would solve the equation when a number is input.
ex.
y=(2/x)*t
x ranges from 0-30
and the input is a value for t.
The main problem is that when i try to use "function" MATLAB says that "function definitions are not permitted in this context"
Accepted Answer
More Answers (1)
per isakson
on 1 Mar 2014
0 votes
- See: Function Basics and
- give it an honest try
- if you run into problems then return here with specific questions
2 Comments
Nicole Isbell
on 1 Mar 2014
per isakson
on 1 Mar 2014
A function shall be defined (/typed) in a text file. The word function on the first line (may optionally be preceded by comments) and the word end (optionally) on the last line. See Create Functions in Files
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!