How is this code getting executed?

9 views (last 30 days)
Varun Rahul Lale
Varun Rahul Lale on 1 Oct 2021
Commented: Walter Roberson on 1 Oct 2021
for i=1 : u
x(:,i) = y(:,ij(i-1))-y(:ij(i-2))
end
  4 Comments
DGM
DGM on 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?
Walter Roberson
Walter Roberson on 1 Oct 2021
for i=1 : u
x(:,i) = y(:,ij(i-1))-y(:,ij(i-2))
end
You were missing a comma

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!