Remove rows from a table based on the amount of rows in another table

2 views (last 30 days)
I have two tables, Table1 and Table2 and I'm using them to create a master table called Final.
Table2 is considerably larger than Table1 and I dont need the extra data it provides in those rows. I can get this to work by just looking at the amount of rows and manually entering this value as below:
% Count rows in Table1
rowsd=size(Table1, 1);
% Remove extra rows in Table2
Table2([35400:end], :)=[];
This will remove the rows I dont need and all is good and I can then write my Final table. However, Table1 size will be different each time I use this script I'm writing due to differing input files. I want it to count the number of rows and then use that answer to automate this process.
I've tried the following but just get an error. Can anybody help please? Thank you
% Count rows in Table1
rowsd=size(Table1, 1);
% Remove extra rows in Table2
Table2([rowsd:end], :)=[];
  5 Comments
Chris Ainsworth
Chris Ainsworth on 28 Feb 2022
I cant paste the exact data sorry however, I noticed when I didnt add the 1 Table2 became a 4040x3 but it should be a 4041x3. It now matches Table1 perfectly. Thanks for your help

Sign in to comment.

Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!