Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
numel 1

Subject: numel 1

From: nuley

Date: 8 Nov, 2012 01:43:14

Message: 1 of 3

Tup=input('What is the higher threshold? ');
Tdown=input('What is the lower threshold? ');
Y=input('What is starting point? ');
Trial=input('How many Trials? ')
for x=1:Trial
    J=1;
    while Y(J)<Tup & Y(J)>Tdown
        Y=Y(J)+normrnd(0,1);
        J=J+1;
    end
    t(x)=J;
    x=x+1;
end
figure(1)
plot(Y,J)
figure(2)
hist(t)

Attempted to access Y(2); index out of bounds because numel(Y)=1.

Error in ScriptFinalProject (line 7)
    while Y(J)<Tup & Y(J)>Tdown

Do you know what the numel(Y)=1 error occurring?

Subject: numel 1

From: Roger Stafford

Date: 8 Nov, 2012 01:59:12

Message: 2 of 3

"nuley" wrote in message <k7f2ni$ocj$1@newscl01ah.mathworks.com>...
> Tup=input('What is the higher threshold? ');
> Tdown=input('What is the lower threshold? ');
> Y=input('What is starting point? ');
> Trial=input('How many Trials? ')
> for x=1:Trial
> J=1;
> while Y(J)<Tup & Y(J)>Tdown
> Y=Y(J)+normrnd(0,1);
> J=J+1;
> end
> t(x)=J;
> x=x+1;
> end
> figure(1)
> plot(Y,J)
> figure(2)
> hist(t)
>
> Attempted to access Y(2); index out of bounds because numel(Y)=1.
>
> Error in ScriptFinalProject (line 7)
> while Y(J)<Tup & Y(J)>Tdown
>
> Do you know what the numel(Y)=1 error occurring?
- - - - - - - -
  Change the line

 Y=Y(J)+normrnd(0,1);

to

 Y(J+1)=Y(J)+normrnd(0,1);

Roger Stafford

Subject: numel 1

From: Roger Stafford

Date: 8 Nov, 2012 02:32:16

Message: 3 of 3

"nuley" wrote in message <k7f2ni$ocj$1@newscl01ah.mathworks.com>...
> plot(Y,J)
- - - - - - -
  Note: I suspect "plot(Y,J)" will not be useful to you since Y will have the longest length attained by any trial whereas its preceding parts will probably be overwritten numerous times by other shorter trials. Also it may not work since J is only a scalar.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

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.

Contact us