- Start your editor
- Write the code (read through your course notes)
- Save the file

# How create a calculator function ?

48 views (last 30 days)

Show older comments

Create a function calculator() that has as input: a: number; b: number; t: textfield containing the mathematical function to perform. The functions to calculate are: “+” “-“ “*” “/”. If another type of function is inputted (e.g. “^”) the output should be NaN. Tip: to verify a text you can use the function “strcmp”. You will also have to use an “if else” statement in your code. Create a proper header.

How do you do this?

##### 3 Comments

James Tursa
on 11 Feb 2015

### Answers (2)

Rick Rosson
on 11 Feb 2015

Here is a start:

function y = calculator(a,b,t)

% Insert your header comments here

%

%

% insert your MATLAB code here:

end

##### 1 Comment

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!