필터 지우기
필터 지우기

Matrix with numeric values

조회 수: 3 (최근 30일)
Nathan McFall
Nathan McFall 2020년 4월 7일
편집: Nathan McFall 2020년 4월 7일
I have assigned letters A through Z a numeric value of 1 through 26, respectively. I have been able to form a 26x19 matrix with these random numeric values. However, I do not know how to convert the entire matrix back to character form.
For example, if part of my matrix is [1 2 3 4], I want it to be [A B C D]. (Note: as said above, I have assigned variable A to equal 1, variable B to equal 2, etc.)
  댓글 수: 1
Stephen23
Stephen23 2020년 4월 7일
"I have assigned letters A through Z a numeric value of 1 through 26..."
Sounds like a complex approach.
A much simpler use of MATLAB ("MATrix LABoratory") would be to use vectors/matrices to store your data.

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

채택된 답변

Birdman
Birdman 2020년 4월 7일
편집: Birdman 2020년 4월 7일
N=4
A=1:N;
B=char(64+A)
'ABCD'
B(1)
'A'
B(2)
'B'
.
.
and so on. Change N and observe the results.
  댓글 수: 3
Birdman
Birdman 2020년 4월 7일
Because char makes conversions based on ASCII table.
Stephen23
Stephen23 2020년 4월 7일
편집: Stephen23 2020년 4월 7일
"why do you have to say char(64 + A), rather than just doing char(A)?"
The character code for 'A' is 65:
MATLAB supports unicode characters up to 65535:

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

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by