- put the code in a function (functions are easier to debug)
- set dbstop if error
- run the function
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. |
0 件のコメント
採用された回答
per isakson
2014 年 7 月 16 日
See
and start with
BTW: V(k) is a scalar
2 件のコメント
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   V(k) is a scalar  whereas   W.'*r   is a column vector
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Debugging and Analysis についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!