How can I import data from an excel file and use it for calculations in GUI?
10 views (last 30 days)
Show older comments
Hello everybody,
I have a little problem with the import of an excel file... I want that the user can coose which file is imported with a button. I have a code, but I allways ger an error code, though I'm following suggestions from thee community. In my excel file I got rawdata of meassurements with 4 FSR sensors. Whenever I'm importing the data i can not make calculations within the button callback code. For testing I wanted to show the mean value of each sensor in a text box. Here is my code so far: dataexcel=uigetfile; data=dataexcel; sensor1=data(:,3); sensor2=data(:,4); sensor3=data(:,1); sensor4=data(:,2); mean1=mean(sensor1); set(handles.text2,'string',mean1); mean2=mean(sensor2); set(handles.text3,'string',mean2); mean3=mean(sensor3); set(handles.text4,'string',mean1); mean4=mean(sensor4); set(handles.text5,'string',mean1);
The thing is, that the values should be between 1 and 0.005, but the values seem to be random (102 for example). Can anybody help me? I can not import the data from excel into my workspace... So I can't calculate later on... Is it beacause I do something wrong with the import of the excel file? I am not able to save the parts of the file to variables... Please help me with my problem :)
1 Comment
Jan
on 26 Mar 2017
Please read Format code in the forum. Posting the complete error message would allow the readers to recognize, what went wrong.
Accepted Answer
Jan
on 26 Mar 2017
Edited: Jan
on 26 Mar 2017
dataexcel=uigetfile; data=dataexcel ???
Then data is the filename of the Excel file. I assume you want the contents of the file:
[FileName, FilePath] = uigetfile();
if isequal(FileName, 0)
disp('User canceled file choosing');
return;
end
data = xlsread(fullfile(FilePath, FileName));
...
0 Comments
See Also
Categories
Find more on Data Import from MATLAB 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!