File Exchange Pick of the Week

September 6th, 2007

MATLAB Basics video: Absolute and Logical indexing

This is one in a series of videos covering MATLAB basics. It is meant for the new MATLAB user.

This video covers how to use row and column notation to be able to pull a subset of data from a larger matrix. This is a basic skill that is required for anyone that is going to use MATLAB. This particular type of indexing is less intuitive than the mat(row,col) indexing, it deals with using a single value as an index into a matrix like mat(ind) and mat([0 1 0 0 1]). These are also very important techniques for indexing into MATLAB.

Find the files here.

Other videos have been gathered here:
http://blogs.mathworks.com/pick/category/video/

Other MATLAB Basics posts have been gathered here:
http://blogs.mathworks.com/pick/category/matlab-basics/

3 Responses to “MATLAB Basics video: Absolute and Logical indexing”

  1. naor replied on :

    Doug, in the RSS feed of your blog, read in internet explorer 7, the videos never show. I don’t mean they don’t run, there are just lines of text with a single blank line where the videos should be. Is there a way to fix this?
    Thanks,
    naor (win32xp r2006a)

  2. Dennis Olly replied on :

    Hi Doug, very clear video, however, is it possible to do logical indexing directly to a submatrix, eg:

    data=zeros(10,10,10);

    here data(:,:,5) could be slice.
    now let

    mask=zeros(10,10);mask(5:5,8:8)=1;

    Is it possible to use this mask to logically index the submatrix data(:,:,5)?

    slice = data(:,:,5);
    and then accessing slice(mask) is possible. But can this not be done directly, without extracting ’slice’?

    Thanks
    Dennis

  3. Doug replied on :

    It will be required to pull out the intermediate values to use that logical matrix or you will need to do some other indexing method.

    Doug

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Zach: Hi Doug and Les, I didn’t have a lot of time to mess with this, but I did find a work-around. I plotted...
  • hamed: k
  • Les: @Zach This isn’t exactly what you are looking for but at least it puts all three parameters on the same...
  • Zach: Thanks for your suggestions Doug. I’ll give that a shot and see what happens. I’ve seen many of...
  • Doug: @Zach, I would say to use plotYYY, because that is close to what you want, but using depth as Y makes sense....
  • Doug: @Teja, I think this will work: http://www.mathworks .com/access/helpdesk /help/techdoc/ref...
  • Gify: merry christmas :) nice christmas tree! Regards, Janet Gify
  • Teja: Dear Doug Is there anyway to plot a surface from nonuniform data without meshgrid and griddata? Basically i...
  • Zach: I’m working with geophysical data, so I’d like to produce a depth profile. The y-axis would be...
  • Doug: @Ashok First, please do not use variable names that are MATLAB commands (std and mean). Second, p(j) should be...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.