looping through columns in the same nxm matrix

3 views (last 30 days)
hey can anybody tell me how to loop through the columns of the same matrix? I got stuck at
% code
for i=1:length(diff12)-1
Phint(i) = diff12(i+1)-diff12(i);
end
but it only does it for the first column. How do i get it to do it for all the columns in diff12?
  2 Comments
kwadwo
kwadwo on 9 May 2013
whos diff12
Name Size Bytes Class Attributes
diff12 912x35 255360 double
but the code is supposed to take the difference as: (row i+1 - row i) continuously from the same j column. then repeat this arimethics for the next j+1 column.
I thought that would be the case with the next code
if true
for i=1:length(diff12)-1
for h=1:35
diff12(h)
Phint(i,h) = diff12(i+1,h)-diff12(i,h);
end
end end
But it returns a 912 by 912 matrix, while its supposed to be a 911 by 35 matrix

Sign in to comment.

Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!