How to read and make calculations with excel data through matlab app designer
12 views (last 30 days)
Show older comments
Hello, i'm a newbbie in matlab!
I have an assignment where I have to use data from an excel sheet, make some calculations and show the result inside the application. These calculations, include finding the minimum, maximum, median and average value from a column of values inside the Excel file. I would also like to perform standard deviation and find the range of the values. I have created an 'open file' button that opens a 'uigetfile' box, letting the user choose the .xlsx file and then saves the path of that file in the text of a label. Then a different button named 'Minimum' should find the minimum value through the column with the values inside the specific .xlsx file. My problem is that, as much as I have researched, I cannot get Matlab to properly read the file, let alone finding the minimum, maximum, median etc. In the code below, I'm trying to test it by printing the excel file data in a label and a text area. (By the way, I'm using Matlab version R2017a and an old 2010 excel version).
Here is my excel file data:
3.7
0.1
3.9
3
4.4
3.1
7.9
5.8
6.2
4.5
4.3
7.1
3.4
6.1
3.8
3.7
3.3
3
3.3
5.2
5.5
7.4
4.8
5
3.7
3.5
3.2
4
5.3
6.9
8
2.8
7
4.3
2.2
4.5
2.6
4
5.3
7.1
4.2
3.1
3.8
3.3
3.3
5.3
5.5
3.5
2.8
7.4
1.5
Here is the code for the 'open file' button:
% [baseName, folder] = uigetfile({'*.xlsx'},'Choose File...');
fullFileName = fullfile(folder, baseName);
app.pathLabel.Text = fullFileName;
app.pathchecker.Text = int2str(fullFileName);
And here is the code i have so far for the 'Minimum' button:
% filename = (app.pathLabel.Text);
col1cell1 = xlsread(filename, 'A1');
app.text_output.Value = col1cell1;
app.label_output.Text = col1cell1;
The latter one gives an error saying: "Error using xlsread (line 260) Worksheet 'A1' not found.", although clearly an 'A1' cell does exist in my excel file.
Can anyone provide some help ? Thank you for your time !
3 Comments
Accepted Answer
Ameer Hamza
on 3 May 2018
Edited: Ameer Hamza
on 3 May 2018
The second input to xlsread() is the sheet number or the range in a complete format such as 'A1:A5'. Change the line like this
col1cell1 = xlsread(filename, 1);
9 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!