Extract range from table
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I imported an existing excel sheet and now want to make a new variable which holds only certain columns of that sheet that I need (in my case participant IDs, randomisation conditions, etc., i.e. row 1, row 49, etc.). I have specified the ranges as variables (see below) but where do I put the range into the code?
% set path to where the session 1 protocol spreadsheet is
% datapath, filename, and sheet are already defined in my code
% import data (spreadsheet with subject overview)
% tildes are used for placeholder arguments
[~,~,Raw]=xlsread(fullfile(datapath,filename),sheet);
% make a table from the Raw cells
% datafile = cell2table(Raw)
Raw = cell2table(Raw);
% we only need certain columns: A=subject ID, AW=randomisation,..., so define needed columns and general range
% e.g. variable = data(line_from:line_to,column)
Subject_ID = Raw(2:end,1);
TT_randomisation = Raw(2:end,49);
Snack_weights = Raw(2:end,59:76);
Height = Raw(2:end,28)
Weight = Raw(2:end,27)
range = [Subject_ID,Height,Weight,TT_randomisation,Snack_weights];
Thank you!
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!