Help with conditional statement
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm trying to create a conditional statement, using the code below. This code attempts to replace the unit name with a new unit name if the CC Key is greater than zero; otherwise, use the previous unit name:
if any(Table1.CC_KEY == 0);
Table1.NEW_UNITNAME = Table1.UNIT_NAME;
else
Table1.NEW_UNITNAME = Table1.UNIT_CC;
end
댓글 수: 2
답변 (1개)
Steven Lord
2018년 10월 3일
If I understand correctly what you want to do, you want to rename one of the variables in your table. Is that correct? If so you could assign the contents of that variable to another then delete the old variable, or you could just change the name of the variable.
Note that some of the functions listed on that first documentation page to which I linked were introduced fairly recently (the removevars function was added in release R2018a, for example) so they won't be available if you're using an older release. But I believe some of the deletion techniques as well as the variable renaming technique will work for all releases containing table.
참고 항목
카테고리
Help Center 및 File Exchange에서 Language Support에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!