Reading Specific Data Into MATLAB from an Excel File
1 view (last 30 days)
Show older comments
I need to read data from the attached file into my program in MATLAB. How do I do this? I only need the columns listed below:
ismart_02_MAN x
ismart_02_MAN y
ismart_02_MAN z
ismart_02_RASI x
ismart_02_RASI y
ismart_02_RASI z
ismart_02_RLEPI x
ismart_02_RLEPI y
ismart_02_RLEPI z
ismart_02_RLMAL x
ismart_02_RLMAL y
ismart_02_RLMAL z
ismart_02_RTOE x
ismart_02_RTOE y
ismart_02_RTOE z
2 Comments
KSSV
on 11 Feb 2019
YOu note down those columns......and pick only those columns by specifying range while reading using readtable or xlsread
Answers (1)
Guillaume
on 11 Feb 2019
One way:
opts = detectImportOptions('Static_pose.xlsx'); %should automatically figure out what part of the excel file is a table
opts.SelectedVariableNames = opts.SelectedVariableNames(contains(opts.SelectedVariableNames, {'MAN', 'RASI', 'RLEPI', 'RLMAL', 'RTOE'})); %only keep variables with MAN, RASI, etc. in their name
t = readtable('Static_pose.xlsx', opts) %read table with only the selected variable names
Another way, if you want to look at other columns before keeping only the ones you want:
opts = detectImportOptions('Static_pose.xlsx'); %should automatically figure out what part of the excel file is a table
fulltable = readtable('Static_pose.xlsx', opts); %get table with all the columns
filteredtable = fulltable(:, contains(fulltable.Properties.VariableNames, {'MAN', 'RASI', 'RLEPI', 'RLMAL', 'RTOE'})); %only keep variables with MAN, RASI, etc. in their name)
I would think you may also want to keep the Frame column.
0 Comments
See Also
Categories
Find more on Spreadsheets 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!