Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matlab 'for loop' help!!

Status
Not open for further replies.

biaozhun

Student
Nov 17, 2020
1
I need a for loop to pick numbers to be saved in an existing matrix, the matrix is the same size as the amount of data (non square). The sequence in which the numbers have to be picked is as shown in the image below. It starts at the dot and follow the arrows to see the order in which numbers should be store.

Maybe it is a simple question but I am stuck, so please help me[love]

WeChat_Image_zzzyzn.jpg
 
Replies continue below

Recommended for you

I doubt you'd use a for loop for that

I'd do the first three by saying

newmatrix(3)=weird_dot_value
newmatrix(6)=oldmatrix(3)
newmatrix(9)=oldmatrix(6)

and so on

//ok there is some structrue there you could put in a loop

for ii=1:12
%stuff goes in here with modulo arithmetic or lots of test cases
end

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor