Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Fibonacci
Date: Sun, 11 Apr 2010 05:09:03 +0000 (UTC)
Organization: Boeing Co
Lines: 19
Message-ID: <hprlhf$d6p$1@fred.mathworks.com>
References: <hprijn$3bl$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1270962543 13529 172.30.248.35 (11 Apr 2010 05:09:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 11 Apr 2010 05:09:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:625448

"Jake " <nathan.a2000@googlemail.com> wrote in message <hprijn$3bl$1@fred.mathworks.com>...
> function fib(n)
> 
> int n;
> 
> if(n==0 ) return;
>     
> else return n * fib(n-1);  // line 7
>     
> 
> I ran it 
> 
> >> fib(8)
> ??? Error: File: fib.m Line: 7 Column: 13
> Missing MATLAB operator.

Looks like you took a C routine, called it an m-file, and ran it. There is no int data type in MATLAB. To return a variable you put it as part of the function line and then set it to a value in the routine ... it is not part of the return statement. Comments use % , not //. You should read the Getting Started and Functions section of the doc.

James Tursa