Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!news.glorb.com!news.aset.psu.edu!support1.mathforum.org!not-for-mail
From: kaancho12 <kaancho12@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: matlab code doesnt work
Date: Sat, 15 Dec 2007 23:50:41 EST
Organization: The Math Forum
Lines: 20
Message-ID: <11132067.1197780702950.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: nitrogen.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1197780702 808 144.118.30.135 (16 Dec 2007 04:51:42 GMT)
X-Complaints-To: news@support1.mathforum.org
NNTP-Posting-Date: Sun, 16 Dec 2007 04:51:42 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:442631


Hi,
I am trying to implement this code (which was on a lecture slide that I found on the internet) but I could not figure out the error code. Any help is appreciated:
price = [74.9	108.34	82.52	47.2    10  8;
78.85	108.9	82.7	47.34   11  6;
79.86	118	83.3	49.44   12  9;
88.53	120.05	81.75	48.23   11  9;
88.84	134.31	81.13	49.25   12  8
];


[n,col] = size(price);
for i=2:n
ret(i,:) = (price(i,:)-price(i-1,:))./price(i-1,:);
end

The error I get is:
??? Error using ==> run
Subscripted assignment dimension mismatch.

Any idea how to modify my subscript to make this work?