for k2 = 1:22
data2 = mean(cellfun(@(x) x(k2,4), thething))
plot(data2,'-')
end
this is my codes. thething is my arrays contain cells. After I run the scripts, the plot just show nothing on it. Please tell me what's wrong with my code?

댓글 수: 8

KSSV
KSSV 2018년 6월 27일
what is size and class of data2?
Kuang-Yu WANG
Kuang-Yu WANG 2018년 6월 27일
it shows a number
Stephen23
Stephen23 2018년 6월 27일
Probably plotting inside the loop is not useful. Put the values in an array, and then plot that after the loop.
Kuang-Yu WANG
Kuang-Yu WANG 2018년 6월 27일
tried. but the result is still. the line do not shows up
Stephen23
Stephen23 2018년 6월 28일
편집: Stephen23 2018년 6월 28일
@Kuang-Yu WANG: your comment states that the size of the data that you are plotting is 1x1: this will not be visible unless you change the marker type. In any case, even if you specify the marker you will not get a line unless you do what I recommended earlier: collect the data into one matrix and then plot it after the loop. The plot help has plenty of examples (in fact all of the examples) showing how to plot matrices, so start by looking at that.
Ankita Bansal
Ankita Bansal 2018년 6월 28일
Hi, can you share " thething" ?
Kuang-Yu WANG
Kuang-Yu WANG 2018년 6월 28일
thething = 63×1 cell array
{ 26×7 double} { 42×7 double} { 28×7 double} { 22×7 double} { 29×7 double} { 26×7 double} { 35×7 double} { 25×7 double} { 35×7 double} { 23×7 double} { 41×7 double} { 22×7 double} { 28×7 double} { 31×7 double} { 30×7 double} { 40×7 double} { 33×7 double} { 32×7 double} { 33×7 double} { 85×7 double} { 49×7 double} { 86×7 double} { 56×7 double} { 70×7 double} { 59×7 double} { 42×7 double} { 65×7 double} { 50×7 double} { 76×7 double} { 44×7 double} { 54×7 double} { 62×7 double} { 82×7 double} { 55×7 double} { 45×7 double} { 66×7 double} { 74×7 double} { 80×7 double} { 47×7 double} { 59×7 double} { 69×7 double} { 45×7 double} {105×7 double} { 98×7 double} {109×7 double} {118×7 double} {102×7 double} { 74×7 double} { 63×7 double} { 77×7 double} {169×7 double} {181×7 double} {240×7 double} {212×7 double} {150×7 double} {243×7 double} {251×7 double} {281×7 double} {281×7 double} {269×7 double} {281×7 double} {281×7 double} {211×7 double}
Stephen23
Stephen23 2018년 6월 28일
@Kuang-Yu WANG: please upload your data in a .mat file by clicking the paperclip button.

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

답변 (1개)

KSSV
KSSV 2018년 6월 27일

0 개 추천

figure
hold on
for k2 = 1:22
data2 = mean(cellfun(@(x) x(k2,4), thething))
plot(data2,'-')
end

댓글 수: 4

Kuang-Yu WANG
Kuang-Yu WANG 2018년 6월 27일
Sorry still don't work.
KSSV
KSSV 2018년 6월 27일
What is class and size of data2?
size(data2)
ans =
1 1
Kuang-Yu WANG
Kuang-Yu WANG 2018년 6월 28일
it works after i use the brush to select the data in screen. however why can't I plot out a line but just many dots?

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

카테고리

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

제품

질문:

2018년 6월 27일

댓글:

2018년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by