How is this code getting executed?

for i=1 : u
x(:,i) = y(:,ij(i-1))-y(:ij(i-2))
end

4 comentarios

David Hill
David Hill el 1 de Oct. de 2021
What is your specific question? I have no idea what you are trying to do.
Varun Rahul Lale
Varun Rahul Lale el 1 de Oct. de 2021
So I have a matrix Y which is 10*7 and an ij array which is something like this :
ij = [1 2;
2 1;
3 4;
4 3;
5 6;
6 5;
7 8;
8 7;
9 10;
10 9;
9 11;
11 9;
10 11;
11 10];
I have to execute yij = yi -yj. I found the above loop in one of the papers that I was referring to. In the end, I have to find the rank of a matrix.
DGM
DGM el 1 de Oct. de 2021
It's unclear what operations you're trying to do. Y is 10x7 and ij is 14x2. You want the result of yi-yj, neither of which are defined. Is this supposed to mean Y*ij(:,1) - Y*ij(:,2)? If so, the array size mismatch means that this won't work either as a matrix multiplication or as an elementwise multiplication. How does the loop example correspond to the problem statement?
for i=1 : u
x(:,i) = y(:,ij(i-1))-y(:,ij(i-2))
end
You were missing a comma

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Productos

Versión

R2021a

Etiquetas

Preguntada:

el 1 de Oct. de 2021

Comentada:

el 1 de Oct. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by