Polyline to line segment
10 ビュー (過去 30 日間)
古いコメントを表示
Hi, I have a cell array result.mat 1X14 cell array which represent 14 different polyline string.Now I am trying to pick only the longest line segments from each of these 14 polyline string. Below is my piece of code. It worked somewhat but not completely. I would like to save each line segments plotted in the graph in a different 1X14 cell array (similar like my 'result.mat'). Could you please assist?
load result.mat;
for i=1:length(result)
t=result{i};
x=t(:,1);
y=t(:,2);
output = [x y];
d = sqrt(sum(abs(diff(output)).^2,2));
[m,idx]=max(d);
str = int2str(i);
output1 = [output(idx,1) output((idx+1),1)];
output2 = [output(idx,2) output((idx+1),2)];
plot(output1,output2,'-','LineWidth',0.5);
text(output1,output2,str,'Color','red','FontSize',10);
hold on;
end
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!