help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set array values from 3 vectors


From: carbonmetrics
Subject: Re: set array values from 3 vectors
Date: Tue, 30 Aug 2011 13:47:03 -0700 (PDT)

I tried to run this code:

projects=5;
startdate=[1 3 5 7 2];enddate=[5 9 7 9 5];value=[100 300 500 700 900];
for i=1:projects
 canvas(i,startdate(i):enddate(i)) = value(i);
end

and get:
ans =

    100   1000   1300   1300   1800    800   1500   1000   1000

What works is:
project=5; canvas=zeros(1,10); startdate=3; enddate=5; value=50;
canvas(startdate:enddate)=value;
this gives:
    0    0   50   50   50    0    0    0    0    0
but, of course this is only a vector/scalar combination.

Henk

--
View this message in context: 
http://octave.1599824.n4.nabble.com/set-array-values-from-3-vectors-tp3778381p3779714.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]