How Vectorize operation?

I need to put a marker, var flag_min_ce to the records that are smaller for a given variable, among the non-zero values, for a given i, for example in column 8, leaving the rest of rows i with 0, ... then must do the same with i = 2, ... works well for i = 1, but from then on he chooses the zeros My code is:
load('MS_Config.txt')
structureMS = {'Algoritmo', 'Imagen', 'proporcion', 'iteracion', 'bw',...
'delta_t', 'tiempo', 'CE', 'MCS', 'MCD', 'W', 'WSS', 'DI',...
'CH', 'DB', 'XB', 'Num_centros', 'Fecha'};
num_images = 32;
num_iterations = 14;
min_ce = [];
for i = 1:num_images
flag_min_ce = MS_Config((MS_Config(:,2) == i),8) == ...
min(MS_Config(MS_Config((MS_Config(:,2) == i),8) > 0, 8))
min_ce = [min_ce; flag_min_ce];
end
a = [min_ce MS_Config ];

6 Commenti

dpb
dpb il 19 Mag 2018
Better to explain the data structure and the desired result; providing a small example generally helps as well as attach enough data that somebody can use it for testing rather than trying to emulate the problem.
Joffre
Joffre il 19 Mag 2018
Modificato: Joffre il 19 Mag 2018
Ok, thanks for your attention, the relevant structure of the data is:
Algoritmo => algorithm of segmentation of image
Imagen => Matrix of image
Iteracion => Algorithm run
bw, delta_t => Parameters of the algorithm
CE, MCS, MCD, W, WSS, DI, CH, DB and XB => Clustering validation index
Num_centros => Number of centers obtained by executing the iteration in the algorithm.
It`s the more important.
I need to put a marker, var flag_min_ce to the records that are smaller for a given variable, among the non-zero values, for a given i, for example in column 8, leaving the rest of rows i with 0.
Thanks
Image Analyst
Image Analyst il 19 Mag 2018
What does "put a marker to the records" mean? In column 8 you want to keep the zeros, but what do you want to other values to be? Unchanged? Something else? Do you just want a new logical vector like markers = column8 ~= 0???
Joffre
Joffre il 19 Mag 2018
Marker or a flag to indicate that this row contains the best run of the algorithm for the image, I want to keep the values of column 8 and effectively add a new column as a logical marker, but of the lowest value different from zero.
...but of the lowest value different from zero...
The lowest value of what? Please pos a relevant example.
Joffre
Joffre il 19 Mag 2018
Ok, the lowest value different from zero for column 8 CVI = CE and for each imagen. In a similar way I will proceed for the other CVI, looking for the lower or higher value according to CVI is verifying, for the case of entropy, the lowest value is sought, see the image below.
Thanks

Accedi per commentare.

Risposte (1)

Jan
Jan il 19 Mag 2018
Modificato: Jan il 19 Mag 2018
I cannot really follow your description. Do you want the lowest value for all elements of column 8, which have the same index in column 2?
What is the relation to the posted code? I guess MS_Config is the shown matrix?
Then:
zeroInC8 = (MS_Config(:, 8) == 0);
MS_Config(zeroInC8, 8) = Inf; % Hide the 0 values
Result = splitapply(@min, MS_Config(:, 8), MS_Config(:, 2))

2 Commenti

Joffre
Joffre il 19 Mag 2018
Thank you, you helped me, I modified your code a bit and you're done.
Image Analyst
Image Analyst il 20 Mag 2018
He's done? But is your problem solved? You have not Accepted this answer, so is it still a problem? If not, please "Accept this answer", otherwise explain what problem(s) remain.

Accedi per commentare.

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Tag

Richiesto:

il 18 Mag 2018

Commentato:

il 20 Mag 2018

Community Treasure Hunt

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

Start Hunting!

Translated by