what does this line do
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Kamil Kacer
el 20 de Nov. de 2020
Respondida: Walter Roberson
el 21 de Nov. de 2020
d{i}(end+1:max(numOfTrainSamples)) = inf;
can anyone tell what does this do d has 3 iteration and numOfTrainSamples is equal to 1
It suppose to do something but when i ran it doeasnt do anything
0 comentarios
Respuesta aceptada
Walter Roberson
el 21 de Nov. de 2020
The code goes through all of the F cell entries, and finds the number of columns in each, recording the number of columns in numOfTrainSamples(i) at each point. It takes the maximum overall of the number of those. As it goes through and finds the distances, it extends the calculated distances out to the maximum number of samples that were encountered, extending with infinities.
The reason it does this is to be able to compare between the different F, by producing distance arrays that are the same size.
By the way, the way it initializes the arrays is incorrect, but in a way that does not matter. The initialization of d{i} with inf values is not needed as long as d is initialized to be a cell with the correct number of entries.
0 comentarios
Más respuestas (1)
John D'Errico
el 20 de Nov. de 2020
It does nothing on its own. A single line of code has little meaning, out of context.
What does it do? It sets some elements of a specific element of one cell in a cell array to inf. Actually, it APPENDS infs to the end of the vector. There will be max(numOfTrainSamples) infs appended.
Why it does that is what really matters.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!