Dimension problem in for loop?
2 ビュー (過去 30 日間)
古いコメントを表示
I have problem with dimensions. Please find the whole code in attachment.
clc;
clear all;
close all;
format long g;
load('Data\data.mat')
X_1 = reshape(transpose(coord{1:4,2:3}),[8,1]);
X_2 = reshape(transpose(coord{5:8,2:3}),[8,1]);
posteriori_standard_deviation = 1.02; %in meter
displacement_vector = [X_2-X_1];
F = [1 0 1 0 1 0 1 0]%; 0 1 0 1 0 1 0 1];
n=4;
x_gravity_epoch1 = (1/n)*(F* X_1);
x_gravity_epoch2 = (1/n)*(F* X_2);
X1_bar_i = X_1 - x_gravity_epoch1';
X2_bar_i = X_2 - x_gravity_epoch2';
% x_bar_i = x_bar_i';
% y_bar_i = y_bar_i';
for i=1:size(X1_bar_i)
H(i,:)= [0 X1_bar_i(i+1,1) X1_bar_i(i,1) -X1_bar_i(i+1,1) 0 1;X1_bar_i(i+1,1) X1_bar_i(i,1) 0 X1_bar_i(i,1) 1 0];
i=i+1;
end
The error is Unable to perform assignment because the indices on the left side are not compatible with the
size of the right side.
0 件のコメント
回答 (1 件)
Cris LaPierre
2021 年 7 月 3 日
I believe the issue is that you are trying to assign a 2-row array into a single row of H. Hence, the dimension mismatch error. If your intent is to assign the array to 2 rows of H, then your row index must include both rows.
% Assignment to 2 rows works
A(1:2,:)=rand(2,6)
% Assignment to 1 row doesn't work
A(3,:)=rand(2,6)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!