Question
I have a table, "patients", with 5 columns. I would like these columns to follow the pattern determined by the cell, "order". How could I do this? Reproduction steps >> load patients >> patients = table(Age,Gender,Height,Weight,Smoker,... 'RowNames',LastName); >> order = {'Gender', 'Gender', 'Age', 'Gender', 'Smoker',... 'Smoker', 'Weight', 'Height', 'Weight'};
Expert Answer
John Michell
PhD Expert
Answered Aug 14, 2026
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)
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →