replacing a row of an existing table with nans

조회 수: 23 (최근 30일)
Danielle Leblance
Danielle Leblance 2017년 11월 9일
답변: Peter Perkins 2017년 11월 16일
if t is a table with a mix of numeric columns and text columns, how can i replace a specific row (let us say row 20 of t) with nan values? I tried
t(20,:)=nan;
t{20,:)=nan;
but both failed.

답변 (2개)

Walter Roberson
Walter Roberson 2017년 11월 9일
NaN cannot be stored in the text columns.

Peter Perkins
Peter Perkins 2017년 11월 16일
In recent versions of MATLAB, you can do this:
>> t = table([1;2;3],["a";"b";"c"])
t =
3×2 table
Var1 Var2
____ ____
1 "a"
2 "b"
3 "c"
>> t{2,:} = missing
t =
3×2 table
Var1 Var2
____ _________
1 "a"
NaN <missing>
3 "c"

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by