problem to implement an algorithm

11 visualizaciones (últimos 30 días)
Khalid Sherif
Khalid Sherif el 24 de Dic. de 2020
Comentada: Khalid Sherif el 25 de Dic. de 2020
I want to implement the algorithm in matlab but what I underlined with red is confusing me a little bit.
Is there a function in matlab that does this action, or do I just type path(i,j) and it will add on its own?
  4 comentarios
William
William el 24 de Dic. de 2020
Given what John said, you should rename 'path' to something else, like 'pathij'. Then at the beginning of the code set
pathij = [];
and at the location of your red line you can use:
pathij = [pathij; i j];
If you can anticipate how many values of i,j there will be (let's say N), then it is more efficient to give the array pathij an explicit size, with:
pathij = zeros(N,2);
n = 1;
Then, at the red line you would use:
pathij(n,:) = [i j];
n = n+1;
Khalid Sherif
Khalid Sherif el 25 de Dic. de 2020
Thank you William, that worked.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by