how to access Cell data

조회 수: 3 (최근 30일)
Jatin Arora
Jatin Arora 2013년 5월 16일
Hello, I have cell array of dimension 200*1 which contains information about an image. I want to store the data of a variable in the cell to a new variable. The cell is of type uint 8.
for example x = sensorscan{1,1}.data.sensor1; the above line stores the value of sensor1 in x.
But now I want that it should run for the entire cell array that is {200*1}. I have tried using for loop but it gives me an error. Regards
  댓글 수: 2
Image Analyst
Image Analyst 2013년 5월 16일
Do you think that if you shared the error message (all the red text in the command window) that someone might actually be able to suggest a solution?
Jatin Arora
Jatin Arora 2013년 5월 16일
Sorry image analyst but I am getting this error
Attempt to reference field of non-structure array.

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

채택된 답변

David Sanchez
David Sanchez 2013년 5월 16일
my_cell = cell(10,1);
% write into a cell
for k=1:size(my_cell,1)
my_cell{k,1} = rand;
end
% read the cell
for k = 1:size(my_cell,1)
x = my_cell{1,1}
end
  댓글 수: 2
David Sanchez
David Sanchez 2013년 5월 16일
I realized I made a mistake: try this out
my_cell = cell(10,1);
% write into a cell
for k=1:size(my_cell,1)
my_cell{k,1} = rand;
end
% read the cell
for k = 1:size(my_cell,1)
x = my_cell{k,1} % missing ";" to present the value of x on command window
end
Jatin Arora
Jatin Arora 2013년 5월 16일
Thanks David for the solution.

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

추가 답변 (1개)

Thomas
Thomas 2013년 5월 16일
This link gives good examples about accessing cell data http://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by