problem in storing data in cell

1 view (last 30 days)
mira
mira on 19 Apr 2015
Commented: Image Analyst on 20 Apr 2015
I have a loop and the result will be different in the loop. I want to store the result in a cell. However, only the last part will display in the cell. here is the result when I run the coding.
new =
[0x512 double]
new =
[]
[143x512 double]
new =
[]
[]
[146x512 double]
what is the problem?

Accepted Answer

Image Analyst
Image Analyst on 20 Apr 2015
Looks like you're initializing new inside a loop, like this
for k = 1 : 3
new = cell(3,1);
new{k} = someArray;
end
You need to take the initialization step out of the loop and put it before the loop, like this:
new = cell(3,1);
for k = 1 : 3
new{k} = someArray;
end
  2 Comments
mira
mira on 20 Apr 2015
Edited: mira on 20 Apr 2015
Thank you..it's work! My I ask another question? I am doing push button GUI but I want to call the other pushbutton using if else. but it doesn't work. every push button will have different result and i only want to display the result in one static text.

Sign in to comment.

More Answers (0)

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!