How do I remove a value from a column, but keep the rest?

4 views (last 30 days)
How do I remove a value from a column but then keep the rest of the values? For instance, say I had a set of values in a table within column six going from top to bottom, but wanted to remove the first value at the top and then keep the rest. What is the proper way to execute that?

Accepted Answer

Image Analyst
Image Analyst on 28 Jan 2023
Assuming you want to get rid of the entire first row of table "t", you could do
t = t(2:end, :); % Extract rows 2 onwards.

More Answers (1)

Arif Hoq
Arif Hoq on 28 Jan 2023
Try this. If there is any issue, please upload your data.
load patients
T = table(LastName,Gender,Age,Height,Weight,Smoker,Systolic,Diastolic)
T = 100×8 table
LastName Gender Age Height Weight Smoker Systolic Diastolic ____________ __________ ___ ______ ______ ______ ________ _________ {'Smith' } {'Male' } 38 71 176 true 124 93 {'Johnson' } {'Male' } 43 69 163 false 109 77 {'Williams'} {'Female'} 38 64 131 false 125 83 {'Jones' } {'Female'} 40 67 133 false 117 75 {'Brown' } {'Female'} 49 64 119 false 122 80 {'Davis' } {'Female'} 46 68 142 false 121 70 {'Miller' } {'Female'} 33 64 142 true 130 88 {'Wilson' } {'Male' } 40 68 180 false 115 82 {'Moore' } {'Male' } 28 68 183 false 115 78 {'Taylor' } {'Female'} 31 66 132 false 118 86 {'Anderson'} {'Female'} 45 68 128 false 114 77 {'Thomas' } {'Female'} 42 66 137 false 115 68 {'Jackson' } {'Male' } 25 71 174 false 127 74 {'White' } {'Male' } 39 72 202 true 130 95 {'Harris' } {'Female'} 36 65 129 false 114 79 {'Martin' } {'Male' } 48 71 181 true 130 92
size(T)
ans = 1×2
100 8
T(1,:)=[]
T = 99×8 table
LastName Gender Age Height Weight Smoker Systolic Diastolic ____________ __________ ___ ______ ______ ______ ________ _________ {'Johnson' } {'Male' } 43 69 163 false 109 77 {'Williams'} {'Female'} 38 64 131 false 125 83 {'Jones' } {'Female'} 40 67 133 false 117 75 {'Brown' } {'Female'} 49 64 119 false 122 80 {'Davis' } {'Female'} 46 68 142 false 121 70 {'Miller' } {'Female'} 33 64 142 true 130 88 {'Wilson' } {'Male' } 40 68 180 false 115 82 {'Moore' } {'Male' } 28 68 183 false 115 78 {'Taylor' } {'Female'} 31 66 132 false 118 86 {'Anderson'} {'Female'} 45 68 128 false 114 77 {'Thomas' } {'Female'} 42 66 137 false 115 68 {'Jackson' } {'Male' } 25 71 174 false 127 74 {'White' } {'Male' } 39 72 202 true 130 95 {'Harris' } {'Female'} 36 65 129 false 114 79 {'Martin' } {'Male' } 48 71 181 true 130 92 {'Thompson'} {'Male' } 32 69 191 true 124 95
size(T)
ans = 1×2
99 8
  1 Comment
TehSharkDood
TehSharkDood on 28 Jan 2023
I forgot to mention I am loading the table data from an excel file.
The picture is an example of what I am trying to do.
Consider the excel file name to be tabledata
Let's just say I was trying to find the maximum value for the year of 2036, I know I would use
YearMax = max(tabledata(: , 6)) but that would include the 2036 as a value.
What is the proper syntax to ignore 2036 and look at the values beneath it?

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!