How do I declare a for loop with a given number of elements?
Show older comments
I have a for loop:
for j=0:0.03
..
end
I want j to run through 100 elements, in ascending order, between 0 and 0.03 (the value 0.03 is hypothetical). Can somebody help me, please?
Accepted Answer
More Answers (1)
DGM
on 15 May 2021
consider using linspace()
for j = linspace(0,0.03,100)
% do things
end
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!