how shall i keep the particular position of a column of a matrix to to repeat for all other columns?????

조회 수: 2 (최근 30일)
this is a code ::::
a1=rand(10,10);
a=a1(:,1);
a=a';
c=ceil(a); %% when err=1 err=1;
maxValueRowWise=max(a');
for k=1:length(maxValueRowWise)
c(a==maxValueRowWise(k))=0;
end
% disp('For err=1')
% c
%%when err=2
err=2;
s=sort(a,2);
twoMaxValueRowWise=s(:,end-1:end);
for k=1:numel(twoMaxValueRowWise)
c(a==twoMaxValueRowWise(k))=0;
end
% disp('For err=2')
% c
%%when err=3
err=3;
s=sort(a,2);
ThreeMaxValueRowWise=s(:,end-2:end);
for k=1:numel(ThreeMaxValueRowWise)
c(a==ThreeMaxValueRowWise(k))=0;
end
% disp('For err=3')
% c
%%when err=4
err=4;
s=sort(a,2);
ThreeMaxValueRowWise=s(:,end-3:end);
for k=1:numel(ThreeMaxValueRowWise)
c(a==ThreeMaxValueRowWise(k))=0;
end
disp('For err=')
c
[y]=find(c==0)
here y indicates the position of error now in a1 the y row element every node will give wrong answer if by round(a1) is 1 than 0 else 1.
this whole process will be running for 10 times and in every iteration this y wont change and it will give error. plz plz plz help me out....
  댓글 수: 3
suchismita
suchismita 2014년 6월 18일
ya here i have set maximum values but can i set as in between values from 0.8 to 0.3.....4 highest values will be taken....?????
suchismita
suchismita 2014년 6월 18일
with maximum value first i want to check i can do this or not...than in my assignment i have to do for minimum and in between 0.8 to 0.3

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 6월 18일
[~,jj] = sort(a(:),'descend');
y1 = sort(jj);
y = y1(1:err);
  댓글 수: 1
suchismita
suchismita 2014년 6월 18일
can you explain it plzzzz... in a1 if the error positions are 2 8 9 10 then in a(2,:),a(8,:),a(9,:),a(10,:) will say as 0. (only in first column checking for maximum value is done not in others)....this will be carried for 10 iteration and in every iteration 2 8 9 10 will be the error positions

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by