yes.. iam back. i have found absolute value for vectors by commanding abs.. now i could not do divide (n1.n2/|n1| |n2|)..

3 views (last 30 days)
yes.. iam back. i have found absolute values for vectors by commanding abs.. now i could not do divide (n1.n2/|n1| n2)..

Answers (1)

KSSV
KSSV on 2 Feb 2017
abs gives you +ve value. In your case what you have to use is norm. If I am not mistaken n1 stand for norm/ magnitude of the vector. You have to follow as below:
n1 = rand(1,10) ;
n2 = rand(1,10) ;
iwant = n1*n2'/(norm(n1)*norm(n2))
  5 Comments
Jan
Jan on 2 Feb 2017
Edited: Jan on 2 Feb 2017
@Ram: It is hard to guess, what you are asking for. Explicit examples would be useful. KSSV's code cannot create an output like "(2.22, .2333, 0.322)", therefore I'm not sure, what this means. Perhaps you want:
Result = acosd((n1 * n2.') / (norm(n1) * norm(n2)))
Ram kumar Masilamani
Ram kumar Masilamani on 3 Feb 2017
@jan: yeah its very hard to understand me. with your answer, I found the answer as follows. My huge doubt is that it is correct value of psi angle..?please leave a reply.. please x1=[6.630]; y1=[12.294]; z1=[-1.457]; x2=[7.613]; y2=[12.686]; z2=[-0.404]; x3=[8.324]; y3=[11.427]; z3=[0.102]; x4=[9.372]; y4=[11.018]; z4=[-0.564]; v1=[x2-x1, y2-y1, z2-z1]
v1 =
0.9830 0.3920 1.0530
v2=[x3-x2, y3-y2, z3-z2]
v2 =
0.7110 -1.2590 0.5060
v3=[x4-x3, y4-y3, z4-z3]
v3 =
1.0480 -0.4090 -0.6660
n1=cross(v1,v2)
n1 =
1.5241 0.2513 -1.5163
n2=cross(v2,v3)
n2 =
1.0454 1.0038 1.0286
x=cos(-1)
x =
0.5403
y=dot(n1,n2)
y =
0.2859
y1=(n1*n2.')
y1 =
0.2859
z=norm(n1).*norm(n2)
z =
3.8468
ans=x.*(y./z)
ans =
0.0402

Sign in to comment.

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!