[R] Problems dealing with matrices
halim10-fes at sust.edu
Sun Nov 24 05:22:02 CET 2013
Thank you very much for your response. Sorry, if I couldn't explain clearly. I
think, I should restate the problem to get exactly what I want. Here it goes:
I have 2 matrices and 1 vector, namely,
What I essentially want to do is to multiply 'dcmat' with 'volmat' and dump
the output in a new matrix 'vol'. But before that, in the first step, I want
to add volinp with volmat[1,1]. So, the first column of the output matrix
'vol' matrix will be:
In the 2nd step, I want to add vol[1,1] with volinp. and replace this value
with volmat[1,1]. The new 'volmat' will look like:
And then multiply 'dcmat' with the new 'volmat', and the 2nd column of output
matrix 'vol' will look like:
Then again, replace the volmat[1,1] with vol[1,2] + volinp and multiply the
new 'volmat' with 'dcmat'. This addition, multiplication, and dumping will
continue up to the length of 'volinp' and the final output matrix 'vol' will
be something like:
[,1] [,2] [,3] ...length(volinp)
[1,] 13.13 1.9669 0.645697 ...
[2,] 61.61 9.2293 3.029809 ...
[3,] 25.25 3.7825 1.241725 ...
[4,] 0.00 0.0000 0.000000 ...
[5,] 0.00 0.0000 0.000000 ...
Within my limited capacity, I've tried to come up with a solution but failed.
I'll appreciate your/others' help with gratefulness.
Md. Abdul Halim
Department of Forestry and Environmental Science
Shahjalal University of Science and Technology,Sylhet-3114,
alt. e-mail: xou03 at yahoo.com
On Sat, 23 Nov 2013 14:10:12 -0800 (PST), arun wrote
> Could you show your expected output? It is a bit unclear from the
> On Saturday, November 23, 2013 2:00 PM, halim10-fes <halim10-
> fes at sust.edu> wrote: Dear R-friends,
> Hope you doing well. I've been trying to deal with the following
> problem for the couple of days but couldn't come up with a solution.
> It would be great if any of you could give some insight into it.
> I have three matrices like:
> 0.00,0.00, 0.58,0.30,0.11,0.00,0.00,0.00,0.46,0.22,
> 0.00,0.00,0.00,0.00, 0.09),nrow=5,ncol=5)
> What I essentially want to do is to add each value in scvol[1,] with
> the volinp[1,1] and then multiply each new volinp with dcvol and
> finally put the outputs in a new matrix.
> Thanks in advance.
> Md. Abdul Halim
> Assistant Professor
> Department of Forestry and Environmental Science
> Shahjalal University of Science and Technology,Sylhet-3114,
> Cell: +8801714078386.
> alt. e-mail: xou03 at yahoo.com
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the R-help