MATLAB: Table linear indexing error MATLAB Why am I getting an error when trying to linear index into my table? >> load patients >> T = table(Gender,Smoker,Height,Weight); >> T(:,4)(T.Smoker==1) Error: ()-indexing must appear last in an index expression. Best Answer The syntax being used is trying to index into a table that has already been indexed into. Instead, index only once to get the desired behavior:>> T(T.Smoker==1, 4)Alternatively, this can be broken up into two lines of code:>> temp = T(:,4); >> temp(T.Smoker==1,:) Related SolutionsMATLAB: How do you order table columns based on a vector with their names This can be done by indexing into the table with the "order" cell.Note: Table columns cannot repeat names so "Age" will only appear once, and all subsequent ones will have the value "Age_1", "Age_2"... >> patients2 = patients(:,order) MATLAB: How to change the axis limit when I have 2 axes in the figure You can use the "yyaxis" and "ylim" commands to set the y-limit for both axes:>> figure>> yyaxis left>> plot(1:10);>> yyaxis right>> plot(2:2:20);>>>> f = gcf;>> yyaxis left>> ylim(f.Children, [0 5]);>> yyaxis right>> ylim(f.Children, [5 10]); Related QuestionHow do you find and replace rows in two tables with some variables in commonHow to set the title of a uitableHow to create a pictogram in MATLABHow to use custom date labels for the x-axis in MATLAB plotsContains() does not recognize the second string as a validDoes the app freeze when loading data to a Table in App Designer and MATLAB R2017bLogical indexing with a structure
Best Answer