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 comentarios

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

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 8 de Mayo de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by