I tried this code but it doesn't work. Anyone can ans.it?Please.

1 次查看(过去 30 天)
Given A = [ 1 120; 1 130; 2 140; 3 180; 3 160 ] B = [ 1 91; 2 92; 3 93 ]
The first column in data A and B describe a key for the data. Now i want to "merge" the two data sets so that the result looks like targetdata = [ 1 120 91; 1 130 91; 2 140 92; 3 180 92; 3 160 93 ]
%Let be given three points A, B, C in the Euclidean plane. Determine the fourth point D on the line BC so that AD is orthogonal to BC.
i tried this code but it doesn't work.
cidx = bsxfun(@eq,DataA(:,1),DataB(:,1)');
m = 1:size(cidx,2)
DataA(cidx(:,m),3) = DataB(m,2);

回答(1 个)

Guillaume
Guillaume 2016-10-17
This seems to be two completely different problems in the same question. I don't see how the first part (creating datatarget) relates to the second part (a geometry problem).
As this is homework, I won't give you the complete solution. Creating datatarget is trivial (just one line) using ismember
As for the geometry problem, this is also easy using vector projection.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by