Creating a matrix on matlab

1 view (last 30 days)
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 Comments
Stephen23
Stephen23 on 22 Jan 2020
Edited: Stephen23 on 22 Jan 2020
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:

Sign in to comment.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 22 Jan 2020
Edited: KALYAN ACHARJYA on 22 Jan 2020
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!