Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7684335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:00:08+00:00 2026-05-31T19:00:08+00:00

I have a 2D matrix that I need to add into a 3D matrix,

  • 0

I have a 2D matrix that I need to add into a 3D matrix, for example:

mx3d <- array(1:60, c(3,4,5))
mx2d <- array(letters[1:15], c(3,5))

Is it possible to add this mx2d into mx3d so that mx3d.new becomes a 3x5x5 matrix? Would it be easier if I convert the matrix as a list? Thanks!

To make it clear, based on what we have in mx2d and mx3d, I want to have something like:

> mx3d.new
, , 1

     [,1] [,2] [,3] [,4] [,5]
[1,]    1    4    7   10  "a"
[2,]    2    5    8   11  "b"
[3,]    3    6    9   12  "c"

, , 2

     [,1] [,2] [,3] [,4] [,5]
[1,]   13   16   19   22  "d"
[2,]   14   17   20   23  "e"
[3,]   15   18   21   24  "f"

, , 3

     [,1] [,2] [,3] [,4] [,5]
[1,]   25   28   31   34  "g"
[2,]   26   29   32   35  "h"
[3,]   27   30   33   36  "i"

, , 4

     [,1] [,2] [,3] [,4] [,5]
[1,]   37   40   43   46  "j"
[2,]   38   41   44   47  "k"
[3,]   39   42   45   48  "l"

, , 5

     [,1] [,2] [,3] [,4] [,5]
[1,]   49   52   55   58  "m"
[2,]   50   53   56   59  "n"
[3,]   51   54   57   60  "o"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:00:09+00:00Added an answer on May 31, 2026 at 7:00 pm
    library(abind)
    mx3d.new <- abind(mx3d, mx2d, along= 2)
    for(i in 1:5) print(mx3d.new[,,i])
    

    Does that work?

    It gives me this:

    > for(i in 1:5) print(mx3d.new[,,i])
    
         [,1] [,2] [,3] [,4] [,5]
    
    [1,] "1"  "4"  "7"  "10" "a" 
    
    [2,] "2"  "5"  "8"  "11" "b" 
    
    [3,] "3"  "6"  "9"  "12" "c" 
    
         [,1] [,2] [,3] [,4] [,5]
    
    [1,] "13" "16" "19" "22" "d" 
    
    [2,] "14" "17" "20" "23" "e" 
    
    [3,] "15" "18" "21" "24" "f" 
    
         [,1] [,2] [,3] [,4] [,5]
    
    [1,] "25" "28" "31" "34" "g" 
    
    [2,] "26" "29" "32" "35" "h" 
    
    [3,] "27" "30" "33" "36" "i" 
    
         [,1] [,2] [,3] [,4] [,5]
    
    [1,] "37" "40" "43" "46" "j" 
    
    [2,] "38" "41" "44" "47" "k" 
    
    [3,] "39" "42" "45" "48" "l" 
    
         [,1] [,2] [,3] [,4] [,5]
    [1,] "49" "52" "55" "58" "m" 
    
    [2,] "50" "53" "56" "59" "n" 
    
    [3,] "51" "54" "57" "60" "o"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that uses JAMA and need to test is a matrix
Say I have a matrix that looks something like this: {{foobar, 77},{faabar, 81},{foobur, 22},{faabaa,
I have a 30000 by 2000 matrix that I need to put in a
I have a quadratic matrix(two-dimensional dynamic array of pointers) and need to change rows/columns
I need some help in this problem I have this matrix in MATLAB: A
I was wondering how to go about this. I have a matrix object that
Have a matrix report now that has Position, Hours and Wages for a location
I have a sparsely populated matrix that's the result of a series of left
I have a class to parse a matrix that keeps the result in an
I have a .rdlc report and it has matrix. that matrix has some money

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.