Creating a matrix on matlab
조회 수: 1 (최근 30일)
이전 댓글 표시
Im trying to create a matrix ( d = [0:0.5:12] ) but matlab keeps giving me the answer
d =
Columns 1 through 5
0 0.500000000000000 1.000000000000000 1.500000000000000 2.000000000000000
Columns 6 through 10
2.500000000000000 3.000000000000000 3.500000000000000 4.000000000000000 4.500000000000000
Columns 11 through 15
5.000000000000000 5.500000000000000 6.000000000000000 6.500000000000000 7.000000000000000
Columns 16 through 20
7.500000000000000 8.000000000000000 8.500000000000000 9.000000000000000 9.500000000000000
Columns 21 through 25
10.000000000000000 10.500000000000000 11.000000000000000 11.500000000000000 12.000000000000000
instead of just the numbers. Is there a way to make it so it doesnt give me the answer with the 'columns' like this?
댓글 수: 2
Stephen23
2020년 1월 22일
편집: Stephen23
2020년 1월 22일
If you don't want MATLAB to display your matrix then don't display it (i.e. use a semicolon afterwards). If you really want to display the values but don't like the format that you are currently using then change the format (read the format documentation for the full list of possible display formats), or write your own display function based on fprintf.
Note that how MATLAB displays values is not the same as how MATLAB stores those values: nothing you change about how the values are displayed will make any difference to how they are stored in memory.
Note that those square brackets are totally superfluous, get rid of them:
채택된 답변
KALYAN ACHARJYA
2020년 1월 22일
편집: KALYAN ACHARJYA
2020년 1월 22일
format shortG
d=0:0.5:12
Command Window:
d =
Columns 1 through 9
0 0.5 1 1.5 2 2.5 3 3.5 4
Columns 10 through 18
4.5 5 5.5 6 6.5 7 7.5 8 8.5
Columns 19 through 25
9 9.5 10 10.5 11 11.5 12
Here d as 1 dimentional array, what you looking for? It's just displaying the all datapoint with mentioning columns number
Try: (With fit in the single line in screen, it would not show thw column number)
d=0:1:12
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!