My goal is to create a 17 x 75 matrix similar to the Excel image below. The first column remains all 0's. Starting from second column, the even columns begin with 0's and the odd columns begin with delta_x (0.2). The pattern continues with 0.2 added to odd and even columns. I believe I have to use a lot of nested for loops and if statements, but I am not getting the results I want. I was able to get the first 3 columns using the code below but am not sure where to go from here:
x_coor = zeros(17,75);delta_x = 0.2; %cm
for i=1:17 if mod(i,2) == 0 x_coor(i,2) = delta_x/2; else x_coor(i,2) = 0; endendfor j=1:17 if mod(j,2) == 0 x_coor(j,3) = 0; else x_coor(j,3) = delta_x; endendfor col=4:75 if mod(col,2) == 0 for row=1:17 if mod(row,2) == 0 x_coor(row,col) = x_coor(row,col-2) + delta_x; end end else for row1 = 1:17 if mod(row1,2) ~= 0 x_coor(row,col) = x_coor(row,col-2) + delta_x; end end endend
**updated code: My even rows look fine; however, my odd rows are still not correct
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/514952/image.png)
Best Answer