How to split and replace value of cell array ?

Hello,
i have a cell array 36x39 cell, and i have a function named 'new', i wanna split the cell_array into two cell_array_1 36x27 and cell_array_2 36x12. also i count both of cell array with 'new' function, so i can get the new value on each row col of cell array. how can i split and replace the cell array with 'new' function ? i code it, but it still doesn't work well
t=[];
for i=1:39
for j=1:36
t=[t cell_array{j,i}];
end
end
t;
it can't replace the cell_array, please help me. Thanks in advance

댓글 수: 1

Jan
Jan 2013년 4월 10일
I do not understand what you 2count both of cell array". What do you want to "replace"?

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

 채택된 답변

Iman Ansari
Iman Ansari 2013년 4월 10일

0 개 추천

This code may help you:
cell_array_1=cell_array(:,1:27);
cell_array_2=cell_array(:,28:39);
for i=1:39
for j=1:36
cell_array{j,i}=[j i];
end
end

댓글 수: 12

Thank you so much, i'm trying to make it as a function, but it can't works
function cell_array_1=template(image)
for i=1:39;
for j=1:36;
cell_array_1{j,i}=new(image,j,i);
end
end
Can you help me iman,what should i do? Thank you
Iman Ansari
Iman Ansari 2013년 4월 10일
What you want to do with this function? Please explain new and image?
it's something like replacement. so, image is cell_array_1 and new is a function that result a number. then, the cell_array_1{j,i} will be replaced with that number as long as the iteration. i just try only the content, and it works.
for i=1:39;
for j=1:36;
cell_array_1{j,i}=new(image,j,i);
end
end
maybe am i wrong with the call of function? function cell_array_1=template(image). How can i call the cell_array_1?
Iman Ansari
Iman Ansari 2013년 4월 10일
Your function gets any error?
tedy
tedy 2013년 4월 10일
no,everything is ok, i just can't call the function. anyway,is it ok to call cell_array_1{j,i} like my function above?
Jan
Jan 2013년 4월 10일
@tedy: Please explain what "I just can't call the function" mean. What do you expect and what happens instead? The code looks ok, such that I cannot imagine, what you struggle with.
tedy
tedy 2013년 4월 10일
편집: tedy 2013년 4월 10일
@jan: How to make this code as a function?
for i=1:39
for j=1:36
cell_array{j,i}=[j i];
end
end
This may be representing my question.
function cell_array=template
for i=1:39
for j=1:36
cell_array{j,i}=[j i];
end
end
after this save it and in command window type:
a=template;
tedy
tedy 2013년 4월 10일
@iman: actually,i don't know what's wrong with my code before,still the same with your code above, but it works! Thank you iman
Iman Ansari
Iman Ansari 2013년 4월 10일
Your problem solved or not?
tedy
tedy 2013년 4월 10일
yes! Thanks brother
Cedric
Cedric 2013년 4월 10일
Don't forget to [ Accept the Answer ] if Iman solved your problem.

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

추가 답변 (0개)

카테고리

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

질문:

2013년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by