MATLAB Answers

Creating a matrix on matlab

조회 수: 13(최근 30일)
Liam Sullivan
Liam Sullivan 22 Jan 2020 18:11
댓글: Liam Sullivan 22 Jan 2020 18:43
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

Stephen Cobeldick
Stephen Cobeldick 22 Jan 2020 18:18
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:
Liam Sullivan
Liam Sullivan 22 Jan 2020 18:43
thank you

로그인 to comment.

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 22 Jan 2020 18:17
편집: KALYAN ACHARJYA 22 Jan 2020 18:26
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
Or without column numbere see here the Walter's answer

  댓글 수: 0

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by