필터 지우기
필터 지우기

How do I loop a fucntion over matrix columns and store the results in a column?

조회 수: 17 (최근 30일)
Hi,
I have an issue writing a while loop correctly. I have a variable (R) with values that are stored in a matrix full of columns and a function (dfaedit), which I would like loop over each of those columns. Each of these loops should produce a result (H) which I would like to store in a seperate matrix column as a list of numerical values.
I was wondering if someone could help me write this while-loop correctly?
Thanks!

채택된 답변

Torsten
Torsten 2022년 1월 10일
If R is your matrix:
[m,n] = size(R);
H = zeros(n,1);
for i = 1:n
r = R(:,i);
H(i) = dfaedit(r );
end
  댓글 수: 3
Torsten
Torsten 2022년 1월 11일
And you call this function as
[m,n] = size(R);
H = zeros(n,1);
for i = 1:n
r = R(:,i);
H(i) = dfaedit(r,1,1,1);
end
?
And what is dfaedit_2 ?
lil brain
lil brain 2022년 1월 11일
This works! Very cool and thank you for the support. The dfaedit_2 was just a different version of the same function I used :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by