# how can i write a code with consecutive number between 0-100 and use this values inside my code?

45 Ansichten (letzte 30 Tage)
isilay aydin am 21 Jul. 2020
Kommentiert: Stephen23 am 22 Jul. 2020
x = 0.05 + (0.1-0.05).*rand(10,1);
i made this code to use number x with different values but i dont want them to be random numbers. how can i write a code with consecutive number between 0-100 and use this values inside my code?
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

waqas am 21 Jul. 2020
Is this what you are looking for?
x = 0.05 + (0.1-0.05).*[0:1:100]';
If you also want to control from which number (from 0:100) the array should start, then may be this line of code would help.
y = 10; %change it to the starting number that you want
x = 0.05 + (0.1-0.05).*[y:1:100]';
##### 5 Kommentare3 ältere Kommentare anzeigen3 ältere Kommentare ausblenden
waqas am 21 Jul. 2020
If it does the job then accept the answer :)
Stephen23 am 22 Jul. 2020

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Roger J am 21 Jul. 2020
Bearbeitet: Roger J am 21 Jul. 2020
x=0:100 % creates 101 elements from 0 to 100
y=x(12) % sets y to the value of x(12)
x = 0.05 + (0.1-0.05).*[0:100]; % do some math to the 101 values before assigning to x
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!