필터 지우기
필터 지우기

construction of a matrix

조회 수: 2 (최근 30일)
samia
samia 2011년 4월 29일
I just filling a matrix T by following this code normally the length is same to Ac but it return length(Ac)+1
(size(Ac)=[1 125] and size(Ac_estm)=[1 125])
P=size(Ac,2); T=[]; for (p=1:P) if Ac(p) < Ac_estm(p) T(p)=0;
else
T(p)=1;
end
T=[T T(p)];
end
==>size(T)=[1 126] why??

채택된 답변

Andrei Bobrov
Andrei Bobrov 2011년 4월 29일
this cycle is not needed
T = Ac >= Ac_estm; % T is logical class
T = +(Ac >= Ac_estm); % T is double
but with loop
T = zeros(size(Ac));
for p=1:length(Ac)
if Ac(p) < Ac_estm(p)
T(p)=0;
else
T(p)=1;
end
end
  댓글 수: 1
samia
samia 2011년 4월 29일
thank you!!!

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

추가 답변 (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