How is this code getting executed?

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

4 commentaires

David Hill
David Hill le 1 Oct 2021
What is your specific question? I have no idea what you are trying to do.
Varun Rahul Lale
Varun Rahul Lale le 1 Oct 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 le 1 Oct 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Produits

Version

R2021a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by