Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!multikabel.net!feed20.multikabel.net!newsfeed.freenet.de!newspeer1.nwr.nac.net!border2.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 15 Dec 2007 23:32:19 -0600
From: John O'Flaherty <quiasmox@yeeha.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: matlab code doesnt work
Date: Sat, 15 Dec 2007 23:32:19 -0600
Message-ID: <t0e9m3lpgph572gaoo8mvga6ul6req0ueu@4ax.com>
References: <11132067.1197780702950.JavaMail.jakarta@nitrogen.mathforum.org>
X-Newsreader: Forte Agent 3.3/32.846
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 35
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-11fmGMGROReCkh4VEKxFGrGYsRV9i/4DWOFhEtUTGiyoqFCLosDAmDMjmfZEsB5HHTA3lZKbh40rDNo!Z6Q5e7TilEjCHimz8zDUPGTt8hD1J/BHwsfTbWedltLl7OGk6emVQYtdeHREcLOkGMhEAYKw
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.36
Bytes: 2256
Xref: news.mathworks.com comp.soft-sys.matlab:442632


On Sat, 15 Dec 2007 23:50:41 EST, kaancho12 <kaancho12@hotmail.com>
wrote:

>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?

It seems to work here- this is the result:
ret = 0         0         0         0         0         0
    0.0527    0.0052    0.0022    0.0030    0.1000   -0.2500
    0.0128    0.0836    0.0073    0.0444    0.0909    0.5000
    0.1086    0.0174   -0.0186   -0.0245   -0.0833         0
    0.0035    0.1188   -0.0076    0.0211    0.0909   -0.1111

Maybe there's a difference between what you pasted in the message and
what you're running.
-- 
John