Stuart’s MATLAB Videos

Watch and Learn

MATLAB Tutorial, processing an Excel file in MATLAB 28

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.

28 CommentsOldest to Newest

vallisha replied on : 1 of 28
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 28
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
Mohammed Qahwaji replied on : 6 of 28
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 28
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 28
hello, 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 28
>>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 28
Hello, 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.
Stuart McGarrity replied on : 11 of 28
xlswrite has a parameter xlRange: writetable also has this option: Stuart
Krupali Katakiya replied on : 12 of 28
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 28
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 28
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 28
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 28
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 28
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. Regards Rishabh Chaturvedi
shivani badodiya replied on : 21 of 28
i followed whole code but getting error which is: Undefined function or variable 'nume1', please suggest me where i am wrong
Stuart McGarrity replied on : 26 of 28
Hi Gaurav, I recommend using readtable if you have headers, and csvread if the data is purely numerical with no headers. The MATLAB OnRamp course is a good introduction to MATLAB:
Max replied on : 27 of 28
Hi, i need help. i have a excel sheet with 3 columns. Column 1 and 2 are lists of planets and column 3 is the distance between two planets. i am trying to create a function which allows the user to imput the name of planet 1 and planet 2 which then outputs the corresponding value in column 3. i have used && logic to identify the correct infomation. My problem is that i am unable to define the rows and columns. Tutorials show: [solar_system_b,txtB,rawB]=xlsread('datafile.xlsx'); [r1,c1]=size(P1); [r1,c2]=size(P2); But when i try to run it i get the following error: Undefined function or variable 'P1'. Error in Test_distance (line 3) %line 3-> [r1,c1]=size(P1); Anyhelp would be appreciated.