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

조회 수: 4 (최근 30일)
TehSharkDood
TehSharkDood 2023년 1월 28일
댓글: TehSharkDood 2023년 1월 28일
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?

채택된 답변

Image Analyst
Image Analyst 2023년 1월 28일
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.
  댓글 수: 2
Image Analyst
Image Analyst 2023년 1월 28일
Try this:
YearMax = max(tabledata(2:end , 6)) % Look only at rows 2 and below
TehSharkDood
TehSharkDood 2023년 1월 28일
Worked 10/10.

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

추가 답변 (1개)

Arif Hoq
Arif Hoq 2023년 1월 28일
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
TehSharkDood
TehSharkDood 2023년 1월 28일
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?

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by