Creating a matrix on matlab

3 visualizzazioni (ultimi 30 giorni)
Liam Sullivan
Liam Sullivan il 22 Gen 2020
Commentato: Liam Sullivan il 22 Gen 2020
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 Commenti
Stephen23
Stephen23 il 22 Gen 2020
Modificato: Stephen23 il 22 Gen 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:
Liam Sullivan
Liam Sullivan il 22 Gen 2020
thank you

Accedi per commentare.

Risposta accettata

KALYAN ACHARJYA
KALYAN ACHARJYA il 22 Gen 2020
Modificato: KALYAN ACHARJYA il 22 Gen 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

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by