how to check values in a cell is smaller than a certain number?

hello i have a 1x12 cell which each of the matrix is No of days in a month(rows) with one column. and the data is average daily temperature. i need to check every values in the cell if they are smaller than 15.5 then do some calculation. how is would that be possible? regards

댓글 수: 2

It's not very clear what is the structure of your cell array as I don't think you're using the correct terms. So can you show or attach a sample of your data? In particular, what's in each cell of your cell array, a matrix with several columns, the first of which is the number of day / month?
From what, I understand it's not the value of each element in the matrix you want to compare to 15.5, it's just the temperature (and not the number of days in the month).
k
k 2014년 10월 16일
편집: k 2014년 10월 16일
here is the image. E is a cell of 1x12. does it make more sence? i need to check every value in cell E if they are smaller than 15.5. if they are smaller then do 15.5-thevalue if not 0.

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

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2014년 10월 16일
편집: Andrei Bobrov 2014년 10월 16일
[EDIT]
HDD = cell(size(E));
for jj = 1:numel(HDD)
HDD{jj} = max(0,15.5 - E{jj});
end
Thorsten
Thorsten 2014년 10월 16일
편집: Thorsten 2014년 10월 16일
Because it's a 1 x 12 cell you can address the i'th cell using E{i}
for i = 1:12
smallvalues = E{i}(E{i} < 15.5);
smallindices = find(E{i} < 15.5);
% your computations ...
end

댓글 수: 2

it is a 1x12 cell but the number of rows varies in each matrix is that gonna effect the code?
No, because cell arrays have been invented to handle different number of elements in each cell.

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

카테고리

도움말 센터File Exchange에서 Data Types에 대해 자세히 알아보기

질문:

k
k
2014년 10월 16일

댓글:

2014년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by