Creating a matrix with for loop
Show older comments
I need to create a matrix that increases or decreases in size with the change in variable n. The matrix should be having only one column and the number of rows need to change with the n value.
The inputs are n, (dx=L/n), L. The matrix that needs to be created should be [0;dx/2;(dx/2+dx);((dx/2+dx)+dx);(((dx/2+dx)+dx)+dx);.....;0.5].
The fourth value of the matrix is simply the third value +dx, this should go on until it reaches 0.5. I can't seem to work out how to make a for loop for this problem.
The number of values in between 0 and 0.5 should also be equal to the n value, so if the n value is 8 the number of values in between should also be 8.
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices 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!