필터 지우기
필터 지우기

In an assignment A(I) = B, the number of elements in B and I must be the same.

조회 수: 1 (최근 30일)
p=3;
L=1000;
x=rand(1,L);
r=zeros(p,1);
W=ones(p,L);
V=zeros(L,1);
for k=1:L
r=[x(k);r(1:p-1)];
V(k) = W.'*r;
end
error In an assignment A(I) = B, the number of elements in B and I must be the same.
| I want to find the value of V(k) which is the result of transpose W times r but I'm getting the above error. would you please tell me how to fix the code. |

채택된 답변

per isakson
per isakson 2014년 7월 16일
See
and start with
  1. put the code in a function (functions are easier to debug)
  2. set dbstop if error
  3. run the function
BTW: V(k) is a scalar
  댓글 수: 2
Rock Rocky
Rock Rocky 2014년 7월 16일
would you please tell me why I'm getting this error ? BTW when I change W from W=ones(p,L) to W= ones(p,1) the code run well without any error.
per isakson
per isakson 2014년 7월 16일
편집: per isakson 2014년 7월 16일
  • What result do you expect from the code?
  • Did you try the three steps I proposed?
  • "run well without any error" . Did you get the expected result?
  • I guess it errors because &nbsp V(k) is a scalar&nbsp whereas &nbsp W.'*r &nbsp is a column vector

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by