looping through columns in the same nxm matrix

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 commentaires

What is output from the command
whos diff12
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

Connectez-vous pour commenter.

Réponses (0)

Catégories

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

Question posée :

le 8 Mai 2013

Community Treasure Hunt

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

Start Hunting!

Translated by