Converting each matrix entry to specific string

조회 수: 3 (최근 30일)
Muhammad Ali Qadar
Muhammad Ali Qadar 2013년 11월 17일
편집: Azzi Abdelmalek 2013년 11월 17일
hi,
I have matrix
A=[1 2 3;4 5 6; 7 8 9]
I wanted to convert each matrix entry to specific string for example
A=[X(1) X(2) X(3);X(4) X(5) X(6); X(7) X(8) X(9)]
Any Suggestion Please!!!
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 17일
What is X ?
Muhammad Ali Qadar
Muhammad Ali Qadar 2013년 11월 17일
its a string that is need to be replaced

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 17일
arrayfun(@(ii) X(ii),A,'un',0)
  댓글 수: 5
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 17일
A=[1 2 3;4 5 6; 7 8 9];
arrayfun(@(ii) sprintf('X(%d)',ii),A,'un',0)
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 17일
편집: Azzi Abdelmalek 2013년 11월 17일
%or
sprintf([repmat('X(%d) ',1,size(A,2)) '\n'],A')

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by