Polyline to line segment

9 views (last 30 days)
Satarupa Khamaru
Satarupa Khamaru on 20 Nov 2017
Commented: Satarupa Khamaru on 20 Nov 2017
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
  2 Comments
Satarupa Khamaru
Satarupa Khamaru on 20 Nov 2017
thanks, next time will follow this tutorial to post any code segments. Could you please kindly assist with this issue?

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics 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!