Effacer les filtres
Effacer les filtres

Help with creating an array!!

2 vues (au cours des 30 derniers jours)
Marnie
Marnie le 3 Avr 2015
Modifié(e) : Mahdiyar le 3 Avr 2015
So I want to create a single column vector with N number of rows. N being a user input number. I want to have 100 and 200 as the first and last numbers but have zeroes as all the rest...
so for a 5,1 vector it would be:
100
0
0
0
200
thanks

Réponse acceptée

Mahdiyar
Mahdiyar le 3 Avr 2015
Modifié(e) : Mahdiyar le 3 Avr 2015
Hi you can use this code
N = input('Enter the value for N\nN = ');
Matrix = zeros(N, 1);
Matrix(1) = 100;
Matrix(end) = 200;

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by