Is there no one with the knowledge of cell operation :(
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hi. i have been asking this question again and again..with no real answer to it..it is supposed to be simple operation. but matlab is disappointing me now.
I have data in 1 cell. i want the values greater than 230 to be moved or copied into another cell. see pic.

so values at V{:,2} is 231,06 and is greater than 230, so with a code it should be moved or copied to next column.
a simple for loop or if ?
suggestions or help please?
댓글 수: 0
답변 (1개)
Sean de Wolski
2014년 3월 18일
편집: Sean de Wolski
2014년 3월 18일
First, you asked the first question on here just a few hours ago. Contributors on this page are unpaid volunteers so it cannot be expected to get an answer immediately.
However, good job clarifying your question with the image!
C = {'hello world';245;220};
isAbove230 = @(x)isnumeric(x) && x>230; % define a function to identify elements above 230
idx = cellfun(isAbove230,C); % where are they?
C(idx) = []; % remove offending elements
Or to make a copy
C230 = C(idx);
댓글 수: 5
Walter Roberson
2014년 3월 18일
And this isn't my only volunteer work.
Image Analyst
2014년 3월 18일
편집: Image Analyst
2014년 3월 18일
For bonus points Sean, and a vote, show how it can be done with the nice new capability of a table.
awda, a nice discussion of cell arrays is in the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
Sean de Wolski
2014년 3월 18일
편집: Sean de Wolski
2014년 3월 18일
Well this would be making the assumption that the first element of the cell is the variable name. Otherwise, if the data is heterogenous elsewhere this would just be a cell array as a variable of a table.
Here is a small example with that assumption:
C = {'HelloWorld';245;220};
T = cell2table(C(2:end),'VariableNames',C(1))
%%Now a few different ways:
FirstWay = T.HelloWorld(T.HelloWorld>230)
SecondWay = T(T{:,1}>230,1)
You can use any combination of T.VarName or T{:,column} in the logical index.
Image Analyst
2014년 3월 18일
You got it. By the way, tables are only in R2013b and later.
Walter Roberson
2014년 3월 18일
I am not convinced that the entries are numeric; I think maybe they are all strings.
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!