getting a matrix from Excel data

213 Ansichten (letzte 30 Tage)
Radoslav Vandzura
Radoslav Vandzura am 4 Dez. 2015
Kommentiert: jgg am 9 Dez. 2015
Hello All. Could you advise me, how can i get a matrix from excel sheet to Matlab? Part of my excel sheet is attached here. Thank you for help...

Antworten (1)

jgg
jgg am 4 Dez. 2015
There are a couple of ways.
  • The simplest way, if you're new to Matlab, is use the the file import tool. It's under the File menu > Import Data.
  • You can also call the import scripts from the command line. For instance https://www.mathworks.com/help/matlab/ref/xlsread.html is probably the command you're looking for. In your example, [numbers,text,all] = xlsread(filename,1,'A1:I3') would read in your information as three matrices, one holding the numbers, the other holding the non-numeric parts (and one of the original data).
  • The importdata command might also be useful: the documentation is here: http://www.mathworks.com/help/matlab/ref/importdata.html
I think in general, if you have mixed data that's both numeric and non-numeric, it's a good idea to try and use the tool first. Some of the other tools may not give you output in the format you expect, or can throw an error if they encounter unexpected data. It will also allow you to handle errors or missing data more naturally.
  2 Kommentare
Radoslav Vandzura
Radoslav Vandzura am 4 Dez. 2015
Yes, I know these ways. But I need insert these data into matrix, because I need analyze data....do clustering and other method for analyze....So I need to have data stored in matrix...
jgg
jgg am 9 Dez. 2015
I think I am confused about what you are trying to do. The methods will put your data in a matrix. Some of them will be numeric, some will be string. These are both acceptable grouping variables (see http://www.mathworks.com/help/stats/grouping-variables.html).
If you need to convert the string variables to numerical categories, you can use the grp2idx command (<http://www.mathworks.com/help/stats/grp2idx.html>) then you can create dummy variables with dummyvar.
If this isn't what you're trying to do, you'll need to explain more clearly or give an example of what you'd like your data to look like.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by