Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-2.

조회 수: 1 (최근 30일)
for i=1:n
for j=1:n
c(i,j)=(Yv(i)./(((Yv(i).^2)-(Yc(j).^2))))*(1/(2*pi))
end
end
for i=1:n
for j=i:n
if i>=j
k(i,j)=1
else i<j
k(i,j)=0
end
end
end
for j=1:n
B(i)=(0.5*0.25*5.7296*0.1222)
end
for i=1:1:n
for j=1:1:n
A(i,j)=(0.5)*(c)*(Cla).*(C(i,j))+k(i,j)
gamma(i)=B(j)./A(i,j)
wj=(C(i,j).*gamma(i))
end
Why is this coming up and how do i fix it, Im not sure where it's going wrong
Screen Shot 2019-11-25 at 12.41.02 PM.png
  댓글 수: 1
the cyclist
the cyclist 2019년 11월 25일
Not related to the error you are getting, but this section
for j=1:n
B(i)=(0.5*0.25*5.7296*0.1222)
end
is strange to me, since it is a loop over j, but you are indexing into B with the variable i.

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

답변 (1개)

the cyclist
the cyclist 2019년 11월 25일
In the line of code giving the error:
A(i,j)=(0.5)*(c)*(Cla).*(C(i,j))+k(i,j)
you are using the full matrix c. Maybe you wanted c(i,j) there?
You don't show what Cla is, but possibly the same problem there?
  댓글 수: 3
Areg Arzoomanian
Areg Arzoomanian 2019년 11월 25일
now i get 'Index in position 2 exceeds array bounds (must not exceed 1).'
the cyclist
the cyclist 2019년 11월 25일
편집: the cyclist 2019년 11월 25일
c is not a constant, because of the following code you show:
for i=1:n
for j=1:n
c(i,j)=(Yv(i)./(((Yv(i).^2)-(Yc(j).^2))))*(1/(2*pi))
end
end
It looks like maybe you mixed up some lower- and upper-case variables? MATLAB is case-sensitive.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by