I am trying to execute below code and I keep getting this error.

a=input('enter the value of mean: ');
P = 1
E=exp (-a)
R=[13,7,0.6]
R1=R(1)
R2=R(2)
R3=R(3)
for n=0:3
R= R(n+1)
Po=P.*R
if P < E
N=n
else
n=n+1
end
end
The error is
Error:Attempted to access R(2); index out of bounds because numel(R)=1.
Error in poisson (line 11)
R= R(n+1)

댓글 수: 1

Running perfectly fine on my machine, is this properly formatted in your program?

댓글을 달려면 로그인하십시오.

 채택된 답변

the cyclist
the cyclist 2017년 5월 30일
The first time through the loop over n, this line
R= R(n+1)
makes R into a scalar value. It is no longer the original vector of length 3. The next time through the loop, you try to access the 2nd element of the vector, but that no longer exists.

댓글 수: 1

qandeel iqbal
qandeel iqbal 2017년 6월 12일
편집: qandeel iqbal 2017년 6월 12일
run on my matlab aftersome formating..thank u for help

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Multibody Modeling에 대해 자세히 알아보기

질문:

2017년 5월 30일

편집:

2017년 6월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by