How does matlab choose a specific column of Excel to form an array

Source: Internet
Author: User

For example:

To make an array of columns A, C, D, e Four, remove column B.

First of all look at the MATLAB read Excel special function Xlsread whether provide the corresponding function.

num = xlsread (filename)

Read the data named filename file, and read the data in Sheet1 by default. FileName to include the file path.

num = Xlsread (filename,sheet)

Read the data in the worksheet sheet named filename file,

num = Xlsread (filename,xlrange)

Read the data named filename file, read the data in Sheet1 by default, read the Xlrange column's

num = Xlsread (filename,sheet,xlrange)

Read the data in the Sheet,xlrange column named filename file sheet

num = Xlsread (filename,sheet,xlrange, ' basic ')

Read the data in the spreadsheet in basic form, the default on systems without Excel for Windows. (Do not know how to translate?) Does it mean that Excel is not supported under Windows? ), the default is a null character if there are no special requirements for worksheets and columns. For example: num= xlsread (filename, ', ', ' basic ').

But I am running under matlab num= xlsread (' D:\program files\matlab\example.xls ', ' ', ' ', ' basic ') error, my is the Windows system

[num,txt,raw]= xlsread (filename)

Num returns a partial array of data in filename, and the TXT portion is expressed in Nan

TXT returns the TXT value of filename

Raw returns an array of cells of the same size as the original array

Example:

[Num,txt,raw]= xlsread (' D:\program files\matlab\example.xls ')

>> Example

num =

???? 1???? 2???? 2???? 3
???? 5???? 6???? 6???? 7
???? 3???? 9???? 8??? 14
?? NaN?? NaN?? NaN???? 5


TXT =

??? ' Yx '??? ' s '??? A


Raw =

??? [1]??? [2]??? [2]??? [3]
??? [5]??? [6]??? [6]??? [7]
??? [3]??? [9]??? [8]??? [14]
??? ' Yx '??? ' s '??? ' A '??? [5]

?

___ = Xlsread (filename,-1)

Interactively open an Excel window under Windows to read data in Excel

Example:

num= xlsread (' D:\program files\matlab\example.xls ',-1)

Select the data in the open Excel first, and then return to Matlab to click OK (for example) in the pop-up window. But it doesn't seem to support the selection of columns, only multi-column continuous selection is supported

[Num,txt,raw,custom]= Xlsread (Filename,sheet,xlrange, ", Functionhandle)

Executes a function that returns multiple types of matrices

Example:

    1. Executes a function on the worksheet and then returns the numeric data
    • ????? Enter the following command at the command line to produce a random normal distribution matrix (Gallery function usage reference help)

????????????? Misc = pi*gallery (' Normaldata ', [10,3],1];
????????????? Xlswrite (' myexample.xlsx ', misc, ' MyData ');

??

    • A function that writes a specific function (where data other than [-3 3] becomes-3 or 3, according to recent principles)

???????? 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

    • Finally, the data processing is implemented according to the function

Trim = Xlsread (' myexample.xlsx ', ' MyData ', ', ', @setMinMax)

(use null characters instead of xrange and basic parameters, where two null characters are used when placeholder placeholders)

2 index of returned data (computed by column)

    • function to meet the requirements of the return index

function [Data,indices] = Setminmax (Data)

? Minval =-3; Maxval = 3;
? indices = [];
?
? 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
?????? indices = [indices K];
??? End
? End

    • Call the specified function

[Trim,txt,raw,idx] = Xlsread (' myexample.xlsx ',... ' MyData ', ' ', ' ', @setMinMax);


>>disp (IDX)

>>7???? 9??? ??? ??? ??? ??? ??? ??? 30

?

These are all variants and usages of the Xlsread function

The two limitations of the Xlsread function are indicated at the end of help:

1? Limitationsxlsread reads only 7-bit ASCII characters (can read only seven-bit ASCII sequences)
2. Xlsread does not the support non-contiguous ranges (non-neighbor reads are not supported, that is, only adjacent rows and columns can be read ~ ~ ~ ~ ~ ~ ~ >_<)

.

?

?

?

?

?

How does matlab choose a specific column of Excel to form an array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.