I need help with my first assignment in matlab.

%
Section: Understanding variables (double) and writing an equation.
% In MATLAB you can describe a variable as an equation. You can set the
% variable x to be equal to two times _pi_ by writing the following:
% x = 2*pi;
%
% In this problem you are given the radius of a circle in the variable
% called _r_ and you are asked to return the area of the circle in the
% variable _area_.
Above is the question they are asking. Below is what I have come up with.
function area = problem3(r)
r=3;
area=pi*r^2;
It says that I still have a syntax problem as well as my return problem should be empty and 0. I do not understand what this means.

Answers (1)

You need to store that code in a file named problem3.m and save it. Then you need to go to the command line and type in something like
problem3(8.14)
The 8.14 would be passed in to your function, where it would be known under the name r . You should remove your r=3 line

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 26 May 2017

Answered:

on 26 May 2017

Community Treasure Hunt

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

Start Hunting!