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


284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/gnuplot.rb', line 284

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