Class: Matrix

Inherits:
Object
  • Object
show all
Defined in:
lib/gnuplot.rb

Instance Method Summary collapse

Instance Method Details

#to_gplot(x = nil, y = nil) ⇒ Object



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/gnuplot.rb', line 307

def to_gplot (x = nil, y = nil)
  xgrid = x || (0...self.column_size).to_a
  ygrid = y || (0...self.row_size).to_a

  f = ""
  ygrid.length.times do |j|
    y = ygrid[j]
    xgrid.length.times do |i|
      if ( self[j,i] ) then
        f << "#{xgrid[i]} #{y} #{self[j,i]}\n"
      end
    end
  end
  
  f
end