필터 지우기
필터 지우기

add index to matrix's rows

조회 수: 1 (최근 30일)
Maryam Hamrahi
Maryam Hamrahi 2016년 6월 1일
댓글: Maryam Hamrahi 2016년 6월 1일
I have a matrix like below:
A= [1 2 4
3 4 2
2 4 5]
With n rows and three columns. I would like to create the following
1: 1 2 4
1: 3 4 2
1: 2 4 5
Thank you all in advance.
  댓글 수: 2
the cyclist
the cyclist 2016년 6월 1일
Can you be more specific about what you mean by "I would like to create the following"? For example, do you want to
  • display those strings to the command window?
  • create or display a cell array with text and numeric entries?
Please give us more detail.
Maryam Hamrahi
Maryam Hamrahi 2016년 6월 1일
I would like to print the data like below:
I think it would be better if I do it with fprintf
what is your suggestion?
1: 1 2 4
1: 3 4 2
1: 2 4 5

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

채택된 답변

the cyclist
the cyclist 2016년 6월 1일
편집: the cyclist 2016년 6월 1일
Here's one way:
fprintf('1: %d %d %d\n',A')
For more complicated examples, you might want to read about the formatSpec in the documentation for fprintf.
  댓글 수: 1
Maryam Hamrahi
Maryam Hamrahi 2016년 6월 1일
Thank you very much for the help.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by