Thread Subject: randn usage error

Subject: randn usage error

From: Vijayalayan T.R.

Date: 4 Nov, 2009 14:32:03

Message: 1 of 3

Hello all,

This is my first post so if its in an inappropriate section, my apologies.
 So this is the situation, I'm working on my postgrad project which involves locating a cell phone and I use Time Difference of Arrival with wavelet denoising filtering. I came across someone else's work which is similar to mine but in a diff technology. So I took up to study his code to get an idea of what I'm supposed to do.

In this test program.
this line is not working

randn('state', 2*(i+j));
        noi1_real=sqrt(pow/(2*oran))*randn(1,1024);

And the error is
??? Error using ==> randn
State must be a double scalar or the output of RANDN('state').

Error in ==> tez5 at 36
        randn('state', t);

Can anyone throw some light on what I'm supposed to do.

Thanks in advance

Cheers
Vi

Subject: randn usage error

From: Wayne King

Date: 4 Nov, 2009 14:42:03

Message: 2 of 3

"Vijayalayan T.R." <xcitingindian@yahoo.com> wrote in message <hcs392$4ve$1@fred.mathworks.com>...
> Hello all,
>
> This is my first post so if its in an inappropriate section, my apologies.
> So this is the situation, I'm working on my postgrad project which involves locating a cell phone and I use Time Difference of Arrival with wavelet denoising filtering. I came across someone else's work which is similar to mine but in a diff technology. So I took up to study his code to get an idea of what I'm supposed to do.
>
> In this test program.
> this line is not working
>
> randn('state', 2*(i+j));
> noi1_real=sqrt(pow/(2*oran))*randn(1,1024);
>
> And the error is
> ??? Error using ==> randn
> State must be a double scalar or the output of RANDN('state').
>
> Error in ==> tez5 at 36
> randn('state', t);
>
> Can anyone throw some light on what I'm supposed to do.
>
> Thanks in advance
>
> Cheers
> Vi

Hi, what are i and j equal to? If you don't assign these in your code, then by default they will be the complex number 0 + 1.0000i and you will get the above error.
Wayne

Subject: randn usage error

From: Peter Perkins

Date: 4 Nov, 2009 16:04:10

Message: 3 of 3

Vijayalayan T.R. wrote:

> randn('state', 2*(i+j));

> And the error is
> ??? Error using ==> randn
> State must be a double scalar or the output of RANDN('state').

As Wayne said, if i and j may be referring to complex values. But even if you fix that, there may be a bigger issue. If your intention is that i and j are loop counters, you almost certainly do _not_ want to be reseeding the generator every time though the loop(s). The only reason for wanting to do that is to ensure a certain kind of reproducability -- so that you can reproduce the results of any given iteration without going through the whole loop.

Take to heart this note in the (current version of the) help:

    Resetting the default stream to the same fixed state allows computations
    to be repeated. Setting the stream to different states leads to unique
    computations, however, it does not improve any statistical properties.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
state Vijayalayan T.R. 4 Nov, 2009 09:34:14
matlab Vijayalayan T.R. 4 Nov, 2009 09:34:14
randn Vijayalayan T.R. 4 Nov, 2009 09:34:13
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com