Calculating the distance between two points and set lambda depending on the distance
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Rubik's Cube in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!