How can I calculate mean on matlab gui?

Hello,
I need to know, how I get data from excel to GUI and calculate this data's mean and standard deviation. This data is one coloumn and 8760 line. Thanks.

Antworten (2)

Eamon
Eamon am 12 Okt. 2016
Bearbeitet: Eamon am 12 Okt. 2016

0 Stimmen

You should be able to use the xlsread function to load the Excel file into Matlab. You can use the mean function and the standard deviation function to calculate those parameters.

6 Kommentare

RIDVAN BICER
RIDVAN BICER am 12 Okt. 2016
but I want to calculate in GUI.
Eamon
Eamon am 13 Okt. 2016
What do you mean? How do you want the GUI to interact with the data?
RIDVAN BICER
RIDVAN BICER am 13 Okt. 2016
I must load excel data by push button in gui. Then by an other push button I must calculate this parameters of this excel data. (1 coloumn and 8760 lines. mean that 8760 values)
Image Analyst
Image Analyst am 13 Okt. 2016
Why not do it all with the same button???
RIDVAN BICER
RIDVAN BICER am 14 Okt. 2016
okey if I want make just one button how can I make it?

Melden Sie sich an, um zu kommentieren.

Image Analyst
Image Analyst am 13 Okt. 2016

0 Stimmen

Try this:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = 'C:\Program Files\MATLAB';
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.xls*');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a workbook file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
% Open Excel workbook:
[numbers, strings, raw] = xlsread(fullFileName)
% Extract column 1 (or whatever).
col1 = numbers(:, 1);
% Compute mean and standard deviation, or whatever
theMean = mean(col1);
stDev = std(col1);
If you want to, you can put that all into two separate button callbacks, but it's a little more complicated, so if you go that route, you'll need to study the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

2 Kommentare

RIDVAN BICER
RIDVAN BICER am 14 Okt. 2016
okey if I want make just one button how can I make it?
Image Analyst
Image Analyst am 14 Okt. 2016
Just use GUIDE to place a button on the GUI, then right click and say View Callback. It will throw you into the editor. Then you can write your code into that function. See the GUIDE tutorial for further instructions: http://blogs.mathworks.com/videos/category/gui-or-guide/

Melden Sie sich an, um zu kommentieren.

Kategorien

Gefragt:

am 12 Okt. 2016

Kommentiert:

am 14 Okt. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by