Structure inside a while loop && pixel distance
3 views (last 30 days)
I want to create a structure that stores my array inside a loop
for Example Every time it will generate a data stored in result array. let's say, I have N result. I want to stored into a 1XN structure. How to do that inside a loop?
I have tried for i=1:10
second Qusetion, For example, I have a M x N array. a pixel (m,n) And I used j=(n-1)*M+m convert pixel into the order in Array(:) Is there a way to know the distance between two pixels?
like (3,2) and (3,3) just have 1 unit distance
But it won't work
Ben11 on 12 Aug 2014
Edited: Ben11 on 12 Aug 2014
Something like this?
N = 10;
YourStructure(N).result = zeros(15); % Initialize the structure
for k = 1:N
YourStructure(k).result = rand(15); % store your array in the structure;
To use a while loop (I based my previous answer on your for-loop sorry):
N = 10;
YourStructure(N).result = zeros(15);
k = 1;
YourStructure(k).result = rand(15);
k = k+1;
======= For your 2nd question, the distance is calculated like so:
with the coordinates of the pixels being [x1 y1] and [x2 y2].