repeating the same statement using loop
Show older comments
Hi all,
I am doing same proces for the three time for the range, doppler and angle information. How to do it just by using one time. I want to use only one loop where i can get Result_R, Result_V, Result_A.
%%%for range information
G2 = f_range_m(1:8:length(timeline_ms),:); %%%%measured range
G1 = OrgiRange(1:8:end,:);
obj = 10;
Result=nan(size(G1,1),obj);
for ix = 1:obj
M = G1(:,ix);
dist = abs(bsxfun(@minus,G2,M));
[~,col] = min (dist,[],2);
Result(:,ix) = diag(G2(:,col));
end
%%%For doppler information
G22 = f_vel_mps(1:8:length(timeline_ms),:); %%%%measured range
G11 = xVelOrgins_g(1:8:end,:);
obj = 10;
Result_V=nan(size(G11,1),obj);
for ix = 1:obj
M = G11(:,ix);
dist = abs(bsxfun(@minus,G22,M));
[~,col] = min (dist,[],2);
Result_V(:,ix) = diag(G22(:,col));
end
%%%for angle information
G222 = s_angQ15(1:8:length(timeline_ms),:); %%%%measured range
G111 = OrgiAngle(1:8:end,:);
obj = 10;
Result_A=nan(size(G111,1),obj);
for ix = 1:obj
M = G111(:,ix);
dist = abs(bsxfun(@minus,G222,M));
[~,col] = min (dist,[],2);
Result_A(:,ix) = diag(G222(:,col));
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!