필터 지우기
필터 지우기

How to show the values are constant inside a cell array

조회 수: 5 (최근 30일)
Auryn_
Auryn_ 2018년 9월 12일
댓글: dpb 2018년 9월 13일
Hi,
I have a cell array that is 4x6. Inside each cell I have 1x31 values.
I am studying the change of my variables in time. Thus, for a t_length=31 (31 values in each cell), I would like to show whether in each cell the values are or not constant.
Could you please help me with it?

답변 (1개)

dpb
dpb 2018년 9월 12일
Presuming interpreted the meaning of "constant" in each cell,
>> c{:} % small demo cell array first,last constant, other two alike
ans =
3 3 3 3
ans =
1 2 3 4
ans =
1 2 3 4
ans =
3.1416 3.1416 3.1416 3.1416
>> cellfun(@(x) all(x==x(1)),c)
ans =
2×2 logical array
1 0
0 1
>>
returns locations in the cell array that all are constant (every value in the vector in the cell are the same).
If the Q? is which cells are equal to each other, that's a "compare one to every other" combinational thing.
  댓글 수: 2
Auryn_
Auryn_ 2018년 9월 13일
Hi,
At the end I would like to plot (in 2D) those regions where my variables are constant in time. So I have my cell array of 4x6. Inside each cell I have 1x31 values. In the end I want to plot the constant regions in time on a 2d plot (4x6). Does it make sense? Thanks!
dpb
dpb 2018년 9월 13일

You're talking about subsections within these vectors that are constant? Is that anywhere within them that diff() two or more points is zero or what other definition is "constant"? What about

v=[0 1 2 2 1 1 2 2 3 4 ...

? What is desired output or what are constraints on inputs?

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by