copy corresponding values of 2nd metrics depend on 1st metrics values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a two metrics in similer size lets say X and Y. I want to check the values in X and it it satisfind the requirement I want to copy coresponding Y element to separate metricxs Z, Z2, Z3
what i did is some thing like this
Z=[]
ii=0
Z2=[]
iii=0
Z3=[]
iiii=0
[RawX, ColX]= size(X)
j=1:RawX;
for n=1:ColX
if 100< X(j)<=300
ii=ii+1
Z(ii)=Y(j);
elseif if 300< X(j)<=400
iii=iii+1
Z2(iii)=Y(j);
else 400<X(j)<=500
iiii=iiii+1
Z3(iiii)=Y(j)
end
end
but im geting error
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
can you please help me
0 commentaires
Réponse acceptée
VBBV
le 30 Nov 2022
Z=[];
ii=0
Z2=[];
iii=0;
Z3=[];
iiii=0;
X = rand(10)
Y = rand(10)
[RawX, ColX]= size(X)
for j=1:RawX;
for n=1:ColX
if 100< X(j,n)<=300
ii=ii+1;
Z(ii)=Y(j,n);
elseif 300< X(j,n)<=400
iii=iii+1;
Z2(iii)=Y(j,n);
else 400<X(j,n)<=500
iiii=iiii+1;
Z3(iiii)=Y(j,n);
end
end
end
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!