필터 지우기
필터 지우기

[Matrix] How to change data from double to cell

조회 수: 1 (최근 30일)
Amir Hamzah UTeM
Amir Hamzah UTeM 2011년 3월 29일
hi, i have this set of matrix x=[33 33 33 44 33 22 11 22 11 11 11 11 33 22 33 22 33 33 22 11 22 22 22 11 11 22 22 11]; i want to change it by assign data 11="PG" 22="PT" 33="ML" 44="CT" so at the end it would be like this,
y=[ML ML ML CT ML PT PG PT PG PG PG PG ML PT ML PT ML ML PT PG PT PT PT PG PG PT PT PG];
Anyone know how to do that?got any ideas? thanks, Amir

채택된 답변

Matt Fig
Matt Fig 2011년 3월 29일
x=[33 33 33 44 33 22 11 22 11 11 11 11 33 22 33 22 33 33 22 11 22 22 22 11 11 22 22 11];
y = num2cell(x);
y(x==11) = {'PG'};
y(x==22) = {'PT'};
y(x==33) = {'ML'};
y(x==44) = {'CT'}
  댓글 수: 1
Amir Hamzah UTeM
Amir Hamzah UTeM 2011년 3월 29일
thanks again matt.. you help me a lot today.. :)

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by