Transfers of given points
1 次查看(过去 30 天)
显示 更早的评论
Hello My name is Vladi,
i need some help with my programm
i want to adjust given x&y-values in such a way that a distance of 100 mm is created at the contour. The x&y-values i read into the system fron an TXT-file.
i dont know how to create this. i tried it like this:
x=[data(:,1)] % regard the first column as x values
y=[data(:,2)] % regard the second column as y values
x_new=[x+100]
y_new=[y+100]
if i plot the curve i have the problem that i hava to much points in the upper an to much points in the lower part
I want to transfer the points exactly vertically so that there is a distance of 100 mm between the contours.
0 个评论
采纳的回答
Walter Roberson
2021-4-20
%some sample data for example
data(:,1) = linspace(0, 11000, 500);
data(:,2) = 9500 .* exp(-0.00048 .* data(:,1));
%the work
ncontour = 10;
contour_dist = 100;
x = [data(:,1)]; % regard the first column as x values
y = [data(:,2)]; % regard the second column as y values
minx = min(x); maxx = max(x);
miny = min(y); maxy = max(y);
for K = 0 : ncontour - 1
offset = K * contour_dist;
tx = x + offset;
ty = y + offset;
mask = minx <= tx & tx <= maxx & miny <= ty & ty <= maxy;
plot(tx(mask), ty(mask));
hold on
end
hold off
xlim auto; ylim auto
7 个评论
Walter Roberson
2021-4-22
编辑:Walter Roberson
2021-4-22
My calculation was wrong before.
x = linspace(0, 11000, 100);
y = 9500 .* exp(-0.00048 .* x);
plot(x, y, 'k');
hold on
r = 100;
g = gradient(x, y);
perp = atan(g) + pi/2; %fixed!
xp = x + r * sin(perp);
yp = y + r * cos(perp);
plot(xp, yp, 'b')
hold off
xlim([0 2000])
dists = sqrt((x-xp).^2 + (y-yp).^2);
plot(dists)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!