help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: building dynamic ranges from matrix


From: avlas
Subject: Re: building dynamic ranges from matrix
Date: Tue, 21 Nov 2017 19:07:40 -0500

El dimarts, 21 de novembre de 2017, a les 19:01:18 EST, avlas va escriure:

  El dimarts, 21 de novembre de 2017, a les 18:52:32 EST, AG va escriure:
  
    Thanks Doug. The range start end matrix is built dynamically at runtime and
    so the number of rows is unknown - could be 2 rows could be 10000.
    
    Do you have any idea how your solution might be generalize for an unknown
    number of rows at runtime?
    I tried using cell arrays as an intermediary. I was trying to put each rows
    ranges in a cell then joining all the ranges stored within the cell to the
    final vector but I can't seem to get it to work. Appreciate the help.
    
    
    
    --
    Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
    
    _______________________________________________
    Help-octave mailing list
    address@hidden
    https://lists.gnu.org/mailman/listinfo/help-octave
    
  Look arrayfun is very fast even for 10000 rows:
  
  x = round(100*randn(10000,2));
  tic,y = arrayfun(@(x,y) x:y, x(:,1), x(:,2), "UniformOutput", false);toc
  Elapsed time is 0.0658202 seconds.
  z=[y{:}];
  size(z)
  ans =
  
          1   584615
  a.
  
  _______________________________________________
  Help-octave mailing list
  address@hidden
  https://lists.gnu.org/mailman/listinfo/help-octave
  
Forgot to add sort before to have always first index smaller (or equal) than 
second:

x = sort(round(100*(randn(10000,2))),2);
tic,y = arrayfun(@(x,y) x:y, x(:,1), x(:,2), "UniformOutput", false);toc
Elapsed time is 0.072608 seconds.
z=[y{:}];
size(z)
ans =

         1   1126672
a.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]