How is this code getting executed?

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

4 个评论

What is your specific question? I have no idea what you are trying to do.
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.
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

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

版本

R2021a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by