Having problem with indexing my table

조회 수: 3 (최근 30일)
Yanjika O
Yanjika O 2020년 5월 24일
답변: Cris LaPierre 2020년 5월 25일
Hi,
I have imported a column from excel file. And wanted to refer several parts of it by indexing.
S=readtable('safe_1.xlsx','Sheet','safe_1','Range','K1:K23026');
s=table({'CS1';'CS2';'CS3'},S([3500:4010; 4500:5010; 6000:6510]));
The reason I want to use above table command is that I want to apply same function with those several parts of S table as follows:
% Apply Function to Groups Within Variables
% Compute the group-wise means of variables in a table, A, and return them as rows in a table, B.
% Create a table where one variable defines groups.
A = table({'test2';'test1';'test2';'test3';'test1'},...
[0.71;-2.05;-0.35;-0.82;1.57],[0.23;0.12;-0.18;0.23;0.41])
% Define the anonymous function to find the mean of an input.
func = @mean;
% func uses an existing MATLAB® function to define the operation.
% Apply the function to each group of data defined by Var1.
B = varfun(func,A,'GroupingVariables','Var1')
% B contains a variable called GroupCount to indicate the number of entries from table A in that group.
Please give me your recommendations.
Thank you in advance.
  댓글 수: 5
Image Analyst
Image Analyst 2020년 5월 24일
What indices? Of A or S or s?
Can you attach safe_1.xlsx?
Yanjika O
Yanjika O 2020년 5월 24일
편집: Yanjika O 2020년 5월 24일
I wanted to look data in S to look like A.
I had returned this error after I try to extract datas from S
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported. Use a row subscript and a variable subscript.

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 5월 25일
It looks like you are trying access a subset of data in your table. Take a look at this video from Exploratory Data Analysis with MATLAB.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by