Be the first to rate this file! 38 downloads (last 30 days) File Size: 4.58 MB File ID: #22236

Indexing into a 3d matrix with a loop

by Doug Hull

 

24 Nov 2008

Code covered by BSD License  

Three minute video shows the indexing into a 3d matrix.

Download Now | Watch this File

File Information
Description

The MATLAB user has this:

clear
clc

M(:,:,1) = [1,2;3,4];
M(:,:,2) = [21,22;23,24];
                    
J = [1,2; 2,1];
                    
They want this:
ans = [1 22
           23 4]
                    
They found that
D = M(:,:,J) % This doesn't work

This video discusses this solution:
                    
[nR, nC] = size(J);
D = zeros(nR,nC);
for r = 1:nR
     for c = 1:nC
           D(r,c) = M(r,c,J(r,c));
     end
end
                    
See more videos without downloading here:
http://blogs.mathworks.com/videos/category/video/

MATLAB release MATLAB 7.7 (R2008b)
Zip File Content  
HTML Files Video from http://blogs.mathworks.com/pick
Other Files 135 Basic indexing 3d.flv,
135 Basic indexing 3d.js,
135 Basic indexing 3d_config.xml,
135 Basic indexing 3d_controller.swf,
135 Basic indexing 3d_nofp_bg.gif,
135 Basic indexing 3d_preload.swf,
FlashTemplate.css,
mCode/main.m,
ProductionInfo.xml,
swfobject.js
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
video Doug Hull 24 Nov 2008 15:51:31
tutorial Doug Hull 24 Nov 2008 15:51:31
3d Doug Hull 24 Nov 2008 15:51:31
indexing Doug Hull 24 Nov 2008 15:51:31
index Doug Hull 24 Nov 2008 15:51:31
could u let me know how do i manipulate individual and a specifi chandra ahekar maruti 08 Feb 2009 23:02:15
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com