Creation of fuction y=0

Bill Denney wsloand at gmail.com
Wed Jun 4 22:11:45 CDT 2008


Doug Stewart wrote:
> alvaro gonzalez wrote:
>   
>> Hi People.
>> My problem is I want create in a time-series about variability, 
>> up-down above 0 (as y=0 represent to line), but the vector 0 I don't 
>> know create!!!. the form that is create to matriz produce error!!!.
>>     
> y(1000) =0;
>
> a= rand(1000)-.5;
> y=y+a;
>
> Is this what you want?
The a = rand(1000) will create a 1000x1000 matrix of random numbers.  
The direct way to do it is just

a = rand(1000,1) - 0.5;

If you have an existing vector, a simpler way to do it is:

y = zeros(1000,1);
a = rand(1000,1) - 0.5;
y = y + a;

And actually that last line can be written as

y += a;

Have a good day,

Bill


More information about the Help-octave mailing list