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!