# Append new column considering the distribution of the elemnts in a column

조회 수: 1 (최근 30일)
Maria 2014년 8월 18일
댓글: Maria 2014년 8월 18일
I have a cell type variable with 20000 rows and 9 columns. For example:
c3
A={ 4197 0 53,0 15 28 254 90202 1996 0
4207 0 45,1 11 62 1762 80402 1996 0
4215 0 15,4 10 49 279 100301 1996 1
4220 0 51,4 7 54 308 80402 1996 0
4221 0 7,6 19 69 100 60110 1996 1
Considering c3, I previously appended a new column to variable A that has the value of 1 if the value in c3 corresponds to the bottom 5th percentile of all the values in c3 and zero otherwise. I am now trying to append another column that has the value of 1 if the value in c3 is in between the 5th to 10th percentile of all the values in c3 and zero otherwise. I tried to apply the previuos code I used by adding the condition 'greater than' (<):
p10Val1 = prctile( [A{:,3}], [10] );
A(:,end+1) = {0}
A(p5Val1< [A{:,3}] <= p10Val1, end ) = {1}
But it is not working.
Can someone help? Thank you.
##### 댓글 수: 2없음 표시없음 숨기기
Please try to use . rather than , in pasting data like that in future. It isn't a big issue, it is just that little bit easier for someone to help you if they can just paste straight from your question into Matlab!
Maria 2014년 8월 18일
You are right. When I copy paste the values they get commas and I forget to change, I am sorry and thank you for the correction.

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

### 채택된 답변

A(p5Val1< [A{:,3}] & [A{:,3}] <= p10Val1, end ) = {1}
You can't use 0 < x < 1 type maths in a Matlab expression, you have to AND together the two components. In this case using & rather than &&.

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

### 카테고리

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

### Community Treasure Hunt

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

Start Hunting!

Translated by