Borrar filtros
Borrar filtros

Fractional steps in for loops

3 visualizaciones (últimos 30 días)
IDN
IDN el 29 de Dic. de 2021
Comentada: IDN el 29 de Dic. de 2021
Hello! This is the first time i am running fractional steps in for loop and i am not sure wheter this is just comepletely wrong or if this is the way it works.
yHH = 1:0.1:3;
for yH = 1:length(yHH)
Function(yH)
end
i get the following output
1
4
3
5
1
3
4
10
So what I was expecting was 1.1,1.2,1.3, etc....but I got the above numbers. Are those index numbers like for example below
1 = 1
2 = 1.1 % index 2 equates to the the second step within then range?
3 = 1.2
4 = 1.3
......
10 = 1.9
Appreciate any help! Thanks!

Respuesta aceptada

Voss
Voss el 29 de Dic. de 2021
yHH = 1:0.1:3;
for yH = 1:length(yHH)
display(yH);
end
yH = 1
yH = 2
yH = 3
yH = 4
yH = 5
yH = 6
yH = 7
yH = 8
yH = 9
yH = 10
yH = 11
yH = 12
yH = 13
yH = 14
yH = 15
yH = 16
yH = 17
yH = 18
yH = 19
yH = 20
yH = 21
compare to:
yHH = 1:0.1:3;
for yH = 1:length(yHH)
display(yHH(yH));
end
1 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 3

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by