Spliting a line segment into desired length segments (Matlab)

  • Context: MATLAB 
  • Thread starter Thread starter mushi
  • Start date Start date
  • Tags Tags
    Length Line Matlab
Click For Summary
SUMMARY

The discussion focuses on splitting line segments of varying lengths into equal minor segments using MATLAB. The user seeks a method to achieve this, emphasizing that the lengths of the segments must be equal rather than the number of segments. The suggested solutions include using the 'linspace' function and the colon operator for generating coordinates of the minor segments. An example provided involves dividing major segments of 3KM, 5KM, and 12KM into 2.5KM segments.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of line segment geometry
  • Knowledge of the 'linspace' function in MATLAB
  • Experience with the colon operator in MATLAB
NEXT STEPS
  • Explore MATLAB's 'linspace' function for generating evenly spaced coordinates
  • Learn about the colon operator syntax in MATLAB for creating sequences
  • Research methods for calculating segment lengths and coordinates in MATLAB
  • Investigate MATLAB's plotting functions to visualize line segments and their divisions
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly those involved in geometric computations, data visualization, and anyone needing to manipulate line segments for engineering or graphical applications.

mushi
Messages
23
Reaction score
0
Hi Guys,

I don't know if I make sense but please try to help me.

I am working in Matlab. I have multiple line segments of different lengths with end point coordinates. I want to split each major segment into multiple minor segments in a way that all segments will have same length. 'linspace' can only control number of segments regardless of their lengths. For me, number of segments are not important, but their lenghts are important (must be equal). I want their coordinates like 'linespace' does. It is not necessary that the full length of all segments will be utilized.

For example:
I have Major segments of:
(1) 3KM (2) 5KM (3) 12KM (with their end points)

I want to get:
I want to divide each major segment into multiple minor segments (say 2.5 KM each) with their coordinates.

Any help will be greatly appreciated.

Mushi
 
Physics news on Phys.org
What is a line segment? Can you give an example of your code?
 
calculate n by dividing the major segment length by the minor length, then use linspace
or
use the colon operator ... 0:2.5:12
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
7K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 40 ·
2
Replies
40
Views
5K
  • · Replies 14 ·
Replies
14
Views
4K