Doug's MATLAB Video Tutorials

March 28th, 2012

MATLAB Tutorial, processing an Excel file in MATLAB

It is very commong to read through all the values in an Excel spreadsheet to process them in MATLAB. Here is a simple example of importing Excel in MATLAB and looping through the values.

7 Responses to “MATLAB Tutorial, processing an Excel file in MATLAB”

  1. vallisha replied on :

    Hello Sir,

    Suppose I have the pixel value, how to find the corresponding pixel position in image ?

    Ex: If the pixel value is 160, i want to get the positions of the pixels in the image for which the value is 160.

  2. Doug replied on :

    @Vallisha,

    This is more of a matrix indexing question. You can use FIND to do that.

    Doug

  3. vallisha replied on :

    Thanks a lot.
    Used this :

    index = find(img(:)== 160)

  4. Chen replied on :

    Hi,

    I can write cells to Excel if numbers are specifid.
    I can write simple matrices to excel.

    But, is it possible to write something like this to excel:

    a=[1 2; 3 4 ; 5 6]
    d={‘Temp’, Time; a}
    xlswrite(‘ExcelNmae’, d);

    Thanks,

    Chen

  5. Doug replied on :

    Take a look at xlswrite.

  6. Mohammed Qahwaji replied on :

    If I have an excel sheet that have only numbers on it. And I want to find how much some values repeated.( like how many times there is number 6 in the excel sheet?) how can I find these values by matlab?

  7. Doug replied on :

    First I would import into MATLAB with XLSREAD. Once you have a matrix in, like

    a = [11 22 33 22 22]

    nnz(a == 22)

    will do what you want for 22.

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).


MathWorks

Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

Doug's picture

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