Hi Folks,
This is probably quite easy, but I can't find a Matrix function or way
to populate a specific element of a matrix with a given value? ie, I
want to tell that element i,j of matrix.a should be 3
My code below is a simple test to populate a 5 by 5 matrix from values
in a CSV text file. The loops etc are messy, but it's just an example.
require "mathn"
i=1
j=1
a = Matrix.zero(5)
File.open("TestData.txt").each do |record|
record.split(",").each do |field|
field.chomp!
if i<5 then
Matrix.a(i,j)=field # <-------------How do I
do this line?
end
if i = 5 then
i = 1
j=j+1
end
i=i+1
end
end
puts a.to_s
Any Help/pointers would be great.
TIA.
Jay.