Stuart’s MATLAB Videos

Watch and Learn

MATLAB Tutorial, processing an Excel file in MATLAB 20

Posted by Doug Hull,

It is very common 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.

20 CommentsOldest to Newest

vallisha replied on : 1 of 20

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.

Chen replied on : 4 of 20


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



Mohammed Qahwaji replied on : 6 of 20

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?

Doug replied on : 7 of 20

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.

Abby replied on : 8 of 20

How can you find the total amount of the column from the excel spreadsheet, by using a formula in Matlab?

Stuart McGarrity replied on : 9 of 20

>>sum(numData(:,1)) would give you the sum of column 1
>>sum(numData) would give you the sum of all columns.

Deepak replied on : 10 of 20


I want to write particular column of an excel sheet with some values (1), the excel sheet already has some values in 20 rows and 6 columns, but at the end of the program i want to add value 1 in 7th column for given 20 rows. Will anyone help me out.

Krupali Katakiya replied on : 12 of 20

hello sir,
i have made a datasheet using text format for a matlab program.and now i want to call a specific data from that list(datasheet).how can i do that? can you help me?

Stuart McGarrity replied on : 13 of 20

Hi Krupali, To confirm, is your data stored in an Excel file (e.g. .xlsx)? What MATLAB function did you use to store it? What does your data look like (i.e. # rows, column, data types, headers)? What version of MATLAB do you have? What have you tried to import the data so far?

Kajal replied on : 14 of 20

Hello sir,
I want all programs run at a time in just 1 click and also it read all programs , database which I want to execute . Can u tell me what I do for that . Is there is any code for linking all programs database or any further process . Please send me as early as possible. I am waiting for that .
Thank u…

Spandana S replied on : 17 of 20

How to read a complex matrix from Excel sheet to Matlab.
For example: 1+1i 2+2i
2-1i 6+2i
I want to read this matrix stored in Excel sheet to Matlab.

stuartmcgarrity replied on : 18 of 20

Hi Spandana, Is there one complex number in each cell? e.g. A2= 1+2i and A3=2+2i or are there two complex numbers in each cell? A2= 1+2i 2+2i

Rishabh Chaturvedi replied on : 20 of 20

Hello sir,
By using Matlab is it possible to read parameter values from excel corresponding to unique codes, to put it in other Excel sheet which already has those unique codes and put parameter values corresponding to those unique codes.

Rishabh Chaturvedi

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide