行列を計算して,代入をしたいのですが,サイズが異なるためできないといわれてしまいます.教えてください.
조회 수: 22 (최근 30일)
이전 댓글 표시
deltax = 10*(1000 /3600);
eya = Ya; eva = abs(va-V); eyTH = YTH;
eTHw = abs(THw-TH); eTHg = abs(THg-TH);
A = [1,deltaT,0,0,0;0,1,0,0,0;0,0,1,deltax,0;0,0,0,1,0;0,0,0,0,0];
B = [0,0,0,0,0;deltaT,0,0,0,0;0,0,0,0,0;0,deltaT,0,0,0;0,0,1,0,0];
C = [1,0,-1,0,0;0,0,0,1,-1];
X = [eya,eva,eyTH,eTHw,eTHg];
Q = 1.5*10^-6; R = 1.0*10^-7; U = 5.0*10^-3;
q = randn(N,1)*sqrtm(Q);
r = randn(N,1)*sqrtm(R);
u = randn(N,1)*sqrtm(U);
Z = [q;r;u;0;0];
x =[0,0,0,0,0];
for k=2:N
X (k,:) =A*X(k-1,:).'+B*Z(k-1,:).'; %個々の部分でエラーが出てしまします.
end
댓글 수: 0
답변 (2개)
Image Analyst
2024년 11월 14일 15:30
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
For example, you aren't telling us what Ya, va, V, etc. are Plus you are not giving us the full error message (ALL the red text) so we don't know what line the error occurs on.
Before the loop, have this
whos A
whos X
whos B
whos Z
But X(k-1,:).' is a row vector transposed so that it's now a column vector. But A is a 2-D matrix, so you're doing a matrix multiply, not an element-by-element multiply, So if A is rows x columns, then X(k-1,:).' better be columns x 1 or else it won't work as a matrix multiply. Did you intens an element-by-element multiply? If so use .* rather than *
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!