Function call problem. How to solve it?

2 views (last 30 days)
tabw
tabw on 19 Aug 2014
Commented: Adam on 19 Aug 2014
I have a function, sliceobject(im). I used another m file to compute the input im. After that I used sliceobject(im) But the output can't show in workspace.
I directly use sliceobject with im input is okay.
how to show the output from sliceobject(im)
  2 Comments
Michael Haderlein
Michael Haderlein on 19 Aug 2014
Please give us the header of the sliceobject function (first line) and the line which executes this function. Maybe, even the entire code of the sliceobject function will be necessary to help you find the error.
tabw
tabw on 19 Aug 2014
function [ ] = SliceObject( im )
number=0;
abc=[];
abcd=[];
N=500;
k=1;
q=1;
l=q+1;
t=1;
constant=1;
control=[];
testvalue=[0];
Structure(N).result=zeros(15);
Result(N).volume=zeros(3);
Cell=im;
[R C]=size(Cell);
temp1=[];
num=0;
result=[];
counter=1;
for i= 1:R
for j=1:C
Cell(j,i);
if (find(Cell(j,i))==1)
temp=[i j];
temp1=cat(2,temp1,temp); % store all the true pixel into array
num=num+1;
end
end
end
a=temp1(counter); % true pixel
b=temp1(counter+1);
while (counter<=(size(temp1,2)-2))
j=(a-1)*R+b;
result=cat(2,result,j);
c=temp1(counter+2);
d=temp1(counter+3);
x=((c-a)^2+(d-b)^2)^(1/2);
if (x <= (2)^(1/2))
else
temp00=[];
temp00=result;
Structure(k).result=temp00;
k=k+1;
result=[];
number=number+1;
end
counter=counter+2;
a=temp1(counter);
b=temp1(counter+1);
end
while (l<=number)
tempcon=(abs(bsxfun(@minus,Structure(q).result',Structure(l).result)));
ans=(tempcon==R|tempcon==R-1|tempcon==R+1);
Tr=find(ans==1);
if (Tr>=1)
Structure(q).result=struct('object',[Structure(q).result Structure(l).result]);
Structure(q).result=Structure(q).result.object;
control=[control,q,l];
a=control;
end
if (l==number)
Result(t).volume=Structure(q).result;
aaa=q;
q=(1:number);
q=setdiff(q,control);
aa=q;
l=q(2);
q=q(1);
if (q==aaa)
control=[control,q];
q=(1:number);
q=setdiff(q,control);
l=q(2);
q=q(1);
end
t=t+1;
else
if (l==2)
l=l+1;
else
y= (isempty(Tr));
if (y==1)
l=l+1;
end
end
while any(l==a) && (l<number)
l=l+1;
end
end
end

Sign in to comment.

Answers (1)

Adam
Adam on 19 Aug 2014
result = sliceobject(im);
should work fine.
Occasionally I find that my workspace doesn't refresh itself so I press F5 or just type e.g. 'result' on the command line to force the update and double check 'result' is in fact in the workspace.
  6 Comments
tabw
tabw on 19 Aug 2014
Actually,I need entire "Result" array of Structure. t=1......until it ends,let's say ,600.
I simply used function [Result]=SliceObject(im) and then [Result]=SliceObject(im).
It should work normally. But, I don't know why It won't work this time
But,nothing popped up and store in workspace
Adam
Adam on 19 Aug 2014
What did happen though? Did the function run to completion? Did you step in with the debugger and check everything was working as expected?

Sign in to comment.

Categories

Find more on Variables in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!