필터 지우기
필터 지우기

How to loop over the columns?

조회 수: 8 (최근 30일)
Bruno
Bruno 2016년 10월 28일
댓글: Bruno 2016년 10월 29일
I have a matrix 101x19, I want to flip each column upside down to turn peaks in valley:
How I can do a loop?
for i=1:length(data);
Flipdata(i,:) = 1.001*max(data,i-1)-(data,i);
end

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 28일
for i=1:size(data,2)
Flipdata(:,i) = 1.001 * max(data(:,i)) - data(:,i);
end
or, with no loop,
Flipdata = repmat(1.001 * max(data), size(data,1), 1) - data;
and if you have R2016b or later
Flipdata = 1.001 * max(data) - data;
  댓글 수: 1
Bruno
Bruno 2016년 10월 29일
Thanks Walter

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by