Why are the results different when calculating a 10 x 3 matrix and a 1 x 3 matrix?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
There is a problem.
The result calculated using a for loop as a 125-row matrix and the result calculated using a 1-row matrix are different.
What is the reason ??
clear all;
Lcam_ang1 = -pi/4;
Rcam_ang1 = pi/4;
A1 = [cos(Lcam_ang1) 0 sin(Lcam_ang1); 0 1 0; (-sin(Lcam_ang1)) 0 cos(Lcam_ang1)];
B1 = [cos(Rcam_ang1) 0 sin(Rcam_ang1); 0 1 0; (-sin(Rcam_ang1)) 0 cos(Rcam_ang1)];
XYZ_rwd21t = [1.30937778204061e-14,-13.8617246105272,22.6275000000000;
4.98412069706843,-14.0972221725972,22.6275000000000;
10.1405192035478,-14.3408597871621,22.6275000000000;
15.4782848683395,-14.5930669220533,22.6275000000000;
21.0071578899899,-14.8543037974684,22.6275000000000;
5.61569879271913e-15,-6.93086230526358,22.6275000000000;
4.98412069706842,-7.04861108629860,22.6275000000000;
10.1405192035478,-7.17042989358107,22.6275000000000;
15.4782848683395,-7.29653346102667,22.6275000000000;
21.0071578899899,-7.42715189873418,22.6275000000000;
2.93832502315486e-15,-1.32495437644941e-15,22.6275000000000;
4.98412069706841,-1.80157025904491e-15,22.6275000000000;
10.1405192035478,-1.88965753591222e-15,22.6275000000000;
15.4782848683395,-1.54697382149079e-15,22.6275000000000;
21.0071578899899,-7.26667087945844e-16,22.6275000000000;
5.06165651171334e-15,6.93086230526358,22.6275000000000;
4.98412069706842,7.04861108629860,22.6275000000000;
10.1405192035478,7.17042989358107,22.6275000000000;
15.4782848683395,7.29653346102667,22.6275000000000;
21.0071578899899,7.42715189873418,22.6275000000000];
for i = 1 : 20
XYZ_rwt212t(i, 1) = (XYZ_rwd21t(i, 1) * B1(1,1) + XYZ_rwd21t(i, 3) * B1(1,3));
XYZ_rwt212t(i, 2) = XYZ_rwd21t(1, 2);
XYZ_rwt212t(i, 3) = (XYZ_rwd21t(i, 1) * B1(3,1) + XYZ_rwd21t(i, 3) * B1(3,3));
end
XYZ_rwt211t = zeros(1, 3);
XYZ_rwd2t=[XYZ_rwd21t(15, 1), XYZ_rwd21t(15, 2), XYZ_rwd21t(15, 3)];
for i = 1 : 1
XYZ_rwt211t(i, 1) = (XYZ_rwd2t(i, 1) * B1(1,1) + XYZ_rwd2t(i, 3) * B1(1,3));
XYZ_rwt211t(i, 2) = XYZ_rwd2t(1, 2);
XYZ_rwt211t(i, 3) = (XYZ_rwd2t(i, 1) * B1(3,1) + XYZ_rwd2t(i, 3) * B1(3,3));
end
test_errorX = XYZ_rwt212t(15, 1) - XYZ_rwt211t(1, 1)
test_errorY = XYZ_rwt212t(15, 2) - XYZ_rwt211t(1, 2)
test_errorZ = XYZ_rwt212t(15, 3) - XYZ_rwt211t(1, 3)
The desired answer is the answer from XYZ_rwt211t below.
Why is the Y value different?
0 Kommentare
Antworten (1)
Walter Roberson
am 28 Mai 2020
XYZ_rwd21t = [1.30937778204061e-14,-13.8617246105272,22.6275000000000;
XYZ_rwt212t(i, 2) = XYZ_rwd21t(1, 2);
Okay, so for the first series, the second column will be a copy of -13.8617246105272
21.0071578899899,-7.26667087945844e-16,22.6275000000000;
XYZ_rwd2t=[XYZ_rwd21t(15, 1), XYZ_rwd21t(15, 2), XYZ_rwd21t(15, 3)];
XYZ_rwt211t(i, 2) = XYZ_rwd2t(1, 2);
For the second one, the second column will be a copy of 7.26667087945844e-16
You are copying from different places; it is not surprising that the results are different.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!