comparing and cross product
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Oday Shahadh
am 8 Jun. 2020
Beantwortet: Walter Roberson
am 8 Jun. 2020
hi guys,
why c in below return with one coulmn, it supposed to return (x,y,z,) vector?
regards
c=zeros[];
for i=1:length(p)
if (L1(i,3)==p(i,3))
c=[c,cross(L1(i,:),p(i,:))];
end
end
2 Kommentare
James Tursa
am 8 Jun. 2020
Besides the fact that zeros[] is not valid MATLAB syntax, the cross product returns a vector and it sounds like that is what you are getting as a result. Can you describe the problem in more detail? Maybe with example inputs and desired output?
Akzeptierte Antwort
Walter Roberson
am 8 Jun. 2020
Your first column of L1 is derived from something minus itself, so the first column is going to be all 0.
Your second column of L1 is derived from something minus itself, so the second column is going to be all 0.
Your third-column is generally non-zero.
Cross-product of [0; 0; something] and [0; 0; something_else] is always going to be 0
>> syms x1 x2 y1 y2
>> cross([x1;y1;z1],[x2;y2;z2])
ans =
y1*z2 - y2*z1
x2*z1 - x1*z2
x1*y2 - x2*y1
but your x1 and x2 and y1 and y2 are all 0, and every term involves one of those variables, so every term is going to come out 0. Therefore your cross-product will come out 0 .
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!