Borrar filtros
Borrar filtros

construction of a matrix

2 visualizaciones (últimos 30 días)
samia
samia el 29 de Abr. de 2011
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??

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 29 de Abr. de 2011
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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by