Split a series of lines into equal parts
    3 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Andrew Poissant
 le 7 Août 2017
  
    
    
    
    
    Réponse apportée : Star Strider
      
      
 le 7 Août 2017
            I have a vector of x values with each x corresponding to an endpoint of a line. Starting at 0, I want to split up each line made by the endpoint x into n number of sections. I have tried linspace but I keep getting an error saying "inputs must be scalars" for the line dx_n = linspace(0, x, 10).
x = [0 138.1308 138.0677 137.9625 137.6261 69.0759 64.8584]
dx_n = linspace(0, x, 10);
0 commentaires
Réponse acceptée
  Star Strider
      
      
 le 7 Août 2017
        Use the arrayfun function:
dn_n = arrayfun(@(x)linspace(0,x,10), x(2:end)', 'Uni',0);      % Cell Array
dn_n = cell2mat(dn_n);                                          % Matrix
You can either keep it as a cell array, or have it as a series of matrix rows.
0 commentaires
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

