필터 지우기
필터 지우기

how to delete particular values in this matrix ?

조회 수: 4 (최근 30일)
Matlab111
Matlab111 2015년 2월 9일
댓글: Matlab111 2015년 2월 10일
[a b]=[ 0.5708 0.0755 0 0 0 0 0
0 0 161.5569 0 84.9907 35.0193 17.0669];
i don't want the values before this
" 0
0 "
and my answer should be like this..
[c d]=[ 0 0 0 0
0 84.9907 35.0193 17.0669];
  댓글 수: 6
Michael Haderlein
Michael Haderlein 2015년 2월 9일
편집: Michael Haderlein 2015년 2월 9일
That's quite a lot of code for this question (and most of the code has nothing to do with the question). What is the criterion? Should everything be deleted until a column of zeros? Should the first three columns be deleted? Or is it something else?
case 1: (what Image Analyst was hinting at)
a=[ 0.5708 0.0755 0 0 0 0 0;
0 0 161.5569 0 84.9907 35.0193 17.0669];
allzeros=find(all(a==0));
b=a(:,allzeros:end);
case 2:
b=a(:,4:end);
If none of these cases are what you're looking for, please give detailed information on what you need and post only relevant code.
Matlab111
Matlab111 2015년 2월 9일
Michael Haderlein- sir, don't go for code just see below i given some example.
question:
c=[0.7893 0.8337 0.1479 0 0 0.1479 0.9993];
1.now i should delete the repeated values in that 'c'.
2.i should delete the values that is displayed before the zeros.
3.And finally i should delete zeros also.
Expected output:
d=[0.9993];

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

채택된 답변

Stephen23
Stephen23 2015년 2월 10일
To solve your (constantly changing) requirement stated in your last comment to my original answer, try this code:
allR111 = [allR11;allR21];
Y3 = true(1,size(allR111,2));
Y3(1:find(abs(allR111(1,:))<1e-6,1,'last')) = false;
Y3(1:find(abs(allR111(2,:))<1e-6,1,'last')) = false;
allR111(:,Y3)
  댓글 수: 1
Matlab111
Matlab111 2015년 2월 10일
Stephen Cobeldick- really thanks sir, you helped me a lot

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

추가 답변 (1개)

Stephen23
Stephen23 2015년 2월 9일
편집: Stephen23 2015년 2월 9일
Try this:
>> c = [0.7893,0.8337,0.1479,0,0,0.1479,0.9993];
>> X = sum(bsxfun(@(a,b)abs(a-b)<1e-6,c(:).',c(:)))<2;
>> X(1:find(c==0,1,'last')) = false;
>> c(X)
ans = 0.9993
As in my answer to your other related question , note that I did not use equality test == or unique with floating point numbers, but instead compared the difference of two values with some tolerance, in this case 1e-6. You can change the tolerance to best suit your problem.
  댓글 수: 7
Matlab111
Matlab111 2015년 2월 9일
편집: Matlab111 2015년 2월 9일
Stephen Cobeldick- sir, i try your logic with my main code ya i'm getting but, actually i want to get like this, just see below... when "r=0" i'm getting correct values that's what i expected but when "r=1" i'm not getting an expected values.
after applying your approach that you given above
and i want the answer should be like this, from column 40 to 71, no problem if it's a repeated values and i want get only that red marked part
Note: i'm getting for correct answer when "r=0", no problem if the values repeated and i have attached my modified code below..
if you not clear just ask me once again.
Stephen23
Stephen23 2015년 2월 10일
I have replied to this in a new answer.

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by