Filter löschen
Filter löschen

how can I save the results of every run in a vector?

3 Ansichten (letzte 30 Tage)
ramin asadi
ramin asadi am 11 Dez. 2015
Kommentiert: Star Strider am 11 Dez. 2015
MATLAB
  2 Kommentare
Kirby Fears
Kirby Fears am 11 Dez. 2015
Is "every run" a function called in a loop? What is returned from each run?
Please give details and examples.
ramin asadi
ramin asadi am 11 Dez. 2015
the result is sum of the latest vector of pixels matrix, it doesnt have a loop, the code is quite simple; I=imread('png0015.bmp'); I1=rgb2gray(I); BW=edge(I1,'sobel'); D=bwdist(BW); u=D(480,:); Z=sum(u)/720; Z for every run is a number and i run this for 60 items. i want to save the amount of Z for every run and then avearage this vector.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 11 Dez. 2015
Bearbeitet: Star Strider am 11 Dez. 2015
Create a counter and use every incremented value of it to specify a particular matrix row (or column) or cell array element:
1:
for k1 = 1:N
x(k1) = ... RESULT OF CALCULATION ...;
end
or:
for k1 = 1:N
x{k1} = ... RESULT OF CALCULATION ...;
end
2:
k1 = 1;
while condition = true
x{k1} = ... RESULT OF CALCULATION ...;
k1 = k1 + 1;
end
See the documentation on matrix indexing for details on how to specify rows or columns.
EDIT — To average the vector after you’ve created it, use the mean funciton:
x_mean = mean(x);
  3 Kommentare
ramin asadi
ramin asadi am 11 Dez. 2015
i think i need to read all 60 image in this loop, but i dont know how??
Star Strider
Star Strider am 11 Dez. 2015
If you want to read 60 images, this is one option:
for k1 = 1:60
I=imread('png0015.bmp'); % Read Each Image File
I1=rgb2gray(I);
BW=edge(I1,'sobel');
D=bwdist(BW);
u=D(480,:);
Z(k1)=sum(u)/720;
end
You obviously want to read different image files. There are ways to do that in a loop, but since I have no idea how you named them, I cannot offer specific code to read each one.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by