Calculating the distance between two points and set lambda depending on the distance
Show older comments
function [xnew,ynew]=koordinaten_interpolieren(xwert,ywert)
sz = size(xwert); % the size of my coordinates
Xi = [xwert,ywert];
distance= size(xwert);
for i=1:sz-1 % the first thing is to calculating the distance but Error Message:
% Index in position 2 exceeds array bounds (must not exceed 1).
distance= (sqrt((xwert(i,1)-xwert(i+1,2)).^2)) + (sqrt((ywert(i,1)-ywert(i+1,2)).^2));
if abstand(i,1) > 15 % if the distance is very long -> i want to step with 0.2
Lambdastep = 0.2;
else
Lambdastep = 1; % if the distance is low -> you don't need so much points so i go with 1 ?
end
Lambda= 0:Lambdastep:distance; % the points i want to plot is with every two points -> that means on the distance between two points ->
% there will be more points
end
sz_l=size(l,2);
xt = zeros(sz_l*(sz(1)-1),2);
for i=1:sz-1
for j=1:sz_l
xwertt=Xi(i,1) + Lambda(j)*(Xi(i+1,1) - Xi(i,1));
ywertt=Xi(i,2) + Lambda(j)*(Xi(i+1,2) - Xi(i,2));
xt((i-1)*d+j,1)= xwertt;
xt((i-1)*d+j,2) =ywertt;
end
end
xnew = xt(:,1)
ynew = xt(:,2)
end
%any ideas to make it better and what can i do against the error message ?
10 Comments
darova
on 12 Nov 2019
IS there a problem? What is the question?
Jan Nabo
on 12 Nov 2019
Jan Nabo
on 12 Nov 2019
Walter Roberson
on 12 Nov 2019
Lambda{i}=0:distance(i,2):distance(i,1); % i want to save individual Lambda with each distance but i don't know how
Jan Nabo
on 12 Nov 2019
Jan Nabo
on 12 Nov 2019
Walter Roberson
on 12 Nov 2019
Lambda{j}
However you want Lambda to vary with the distance so you create a vector for each Lambda, and recalling it us going to give you a vector. That is going to make the expression it is involved in into a vector. You then try to store the vector into a scalar location.
Walter Roberson
on 12 Nov 2019
Lambda{i}(j) looks plausible
Jan Nabo
on 13 Nov 2019
Answers (0)
Categories
Find more on Image Arithmetic 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!