Help with MATLAB help example.

1 visualización (últimos 30 días)
Khanh
Khanh el 16 de Sept. de 2014
Editada: Stephen23 el 16 de Sept. de 2014
Hi,
Could someone please explain to me some definitions of the following example of MATLAB help?
The name of the example: Execute a Function on a Worksheet and Return Numeric Data The following function is used for a excel file:
function [Data] = setMinMax(Data)
minval = -3; maxval = 3;
for k = 1:Data.Count
v = Data.Value{k};
if v > maxval || v < minval
if v > maxval
Data.Value{k} = maxval;
else
Data.Value{k} = minval;
end
end
end
In the Command Window, add data to myExample.xlsx.
misc = pi*gallery('normaldata',[10,3],1);
xlswrite('myExample.xlsx', misc, 'MyData');
Read the data from the worksheet, and reset any values outside the range [-3, 3]. Specify the sheet name, but use '' as placeholders for the xlRange and 'basic' inputs.
trim = xlsread('myExample.xlsx','MyData','','',@setMinMax)
In the first line, the name of the data output and the data input are Data . Is this the default name of the excel data? How can I found it in MATLAB help?
Thanks.
Khanh.

Respuesta aceptada

Michael Haderlein
Michael Haderlein el 16 de Sept. de 2014
This is an example of xlsread and its ability to apply a function on the data before returning the data.
There is no need to name the variable in the function header "Data". It's just convenient as it describes what's in there. You can call it just the way you want. You just need to change it in the entire setMinMax function.

Más respuestas (1)

Stephen23
Stephen23 el 16 de Sept. de 2014
Editada: Stephen23 el 16 de Sept. de 2014
"In the first line, the name of the data output and the data input are Data"
Are you referring to this line?:
function [Data] = setMinMax(Data)
If, so then Data is simply a variable that can be passed both to and from the function being defined. Maybe the function help could be useful to read.
There is no "default name of the excel data", which (if using the function xlsread ) can be allocated to a variable of your choice, such as your code:
trim = xlsread('myExample.xlsx','MyData','','',@setMinMax)

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by