Effacer les filtres
Effacer les filtres

Create a vector in Matlab

1 vue (au cours des 30 derniers jours)
klipya
klipya le 2 Août 2012
Hi
I have a question. I've a number in one variable called x, for example, 0.9. I need to create a vector in Matlab with 2500 positions and, in the positions 250 to 360, to copy that number and the rest of the numbers, with 0. How can I code it?
It's something like this:
0
0
0
0
0
0
0
0.9 (in the position 250)
0.9
0.9
...
0.9 (in the position 360)
0
0
0
0 (since 2500)

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 2 Août 2012
simple example:
I = zeros(1,10)
i1 = 5
i2=7
I(i1:i2) = .9
  1 commentaire
klipya
klipya le 2 Août 2012
Thank you so much!

Connectez-vous pour commenter.

Plus de réponses (1)

Alexander
Alexander le 2 Août 2012
A=zeros(2500,1);
A(250:360)=x;
  1 commentaire
klipya
klipya le 2 Août 2012
Thanks you a lot! It works perfectly! ;)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by