how can i create a column vector with specific values?
62 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
giancarlo maldonado cardenas
il 12 Giu 2022
Risposto: Dhritishman
il 15 Giu 2022
Hello how are you? How can I create a column vector with specific values, that is, the first value would have to be 0, the second would have to be 63 up to 1, the vector would have to be as follows.
vec= [0
63
62
.
.
2
1]
any help is helpful.
0 Commenti
Risposta accettata
Più risposte (1)
Dhritishman
il 15 Giu 2022
You can use the colon operator provided by MATLAB to create a vector with specified increment/decrement.
Writing
vec = 63:-1:1
will create a row vector of 63 consecutive values starting from 63 and going all the way down till 1.
But you need to transpose it so as to convert it into a column vector.
vec = (63:-1:1).'
Finally,
vec = [0; (63:-1:1).']
will return you a column vector with the first element as 0 and the next 63 consecutive numbers.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!