×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Matrix with vector as element or 3d matrix or 3d tensor needed

Matrix with vector as element or 3d matrix or 3d tensor needed

Matrix with vector as element or 3d matrix or 3d tensor needed

(OP)
Hi,

i am a new matlab user. I need to generate a above mentioned (subject) datatype. Is it possible. Thanks for your help in advance.

jfrenzel

RE: Matrix with vector as element or 3d matrix or 3d tensor needed

Yes, you can define a 3D matrix. For example, a 3x3x3 matrix of 1's

A(:,:,1) = [1, 1, 1; 1, 1, 1; 1, 1, 1];
A(:,:,2) = [1, 1, 1; 1, 1, 1; 1, 1, 1];
A(:,:,3) = [1, 1, 1; 1, 1, 1; 1, 1, 1];
% A is a 3x3x3 3d matrix

The indices are in the form (row,column,page)

So to extract the second page of this 3d matrix, A, you would use

B = A(:,:,2); % B is a 3x3x1 3d matrix

However, this will still leave you with a 3D matrix (3x3x1) but the 3rd dimension will have a value of 1. Some matlab functions don;t like this. Using the "squeeze" function removes these "singleton" dimensions

C = squeeze(A(:,:,2); % C is a 3x3 2d matrix

I don't think you can perform tensor calculations directly though although there may be some toolboxes available.

Full versions of matlab support n-dimensional spaces. "Student" versions are restricted to 3d I think.

Older versions of Matlab do not support anything above 2D matrices.

M

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources