Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

help needed regarding an error using functions

Status
Not open for further replies.

austinpowers

Electrical
Joined
Oct 21, 2005
Messages
25
Location
US
error : One or more output arguments not assigned during call

 
Some code/context may help. The function is defined with a number of output arguments. ie the first line of the function m file is

function [output1 output2] = myfunction(input1 input2)

and you are calling the function with

[output1] = myfunction(input1 input2)

M

--
Dr Michael F Platten
 
[S1,S2,x,y,w,h,width,height,area,best,worst,temp]=simulatedannealing(seq1,seq2,T0,A,B,Mt,MAXTIME,x,y,w,h,width,height,oldarea,N,M);

thats a simulatedannealing function that i am calling from my main function called sequencepair

and then my called function

function [S1,S2,x,y,w,h,width,height,area,bestarea,worstarea,temp]=simulatedannealing(seq10,seq20,T0,A,B,Mt,MAXTIME,x,y,w,h,width,height,area,N,M)

and i am also calling a metropolis function from this simulated annealing function.

[S1,S2,x,y,w,h,width,height,area,best,worst,temp]=metropolis(S1,S2,T,Mt,x,y,w,h,width,height,area,N,M);

And my called function

function [S1,S2,x,y,w,h,width,height,area,best,worst,temp]=metropolis(S1,S2,T,Mt,x,y,w,h,width,height,oldarea,N,M)

This is what i have done.
I am getting this error

??? One or more output arguments not assigned during call to 'C:\MATLAB701\work\metropolis.m (metropolis)'.

Error in ==> simulatedannealing at 9
[S1,S2,x,y,w,h,width,height,area,best,worst,temp]=metropolis(S1,S2,T,Mt,x,y,w,h,width,height,area,N,M);

Error in ==> sequenepair at 19
[S1,S2,x,y,w,h,width,height,area,best,worst,temp]=simulatedannealing(seq1,seq2,T0,A,B,Mt,MAXTIME,x,y,w,h,width,height,oldarea,N,M);


everything seems right for me , i am not able to figure out whats wrong , can anyone helpme with this
 
my metropolis function is the innermost function,it returns some value to simulated annealing function and then simulated annealing function returns some values to main sequence pair function.

Actually there is a while loop inside this metropolis function ,until some condition is satisfied this metropolis function is run.and the values that are going to be outputted by this metropolis function is defined and assigned in the while loop. once it comes out the loop the program should be having those assigned values and it should return it.but if i run like that i am getting the error stated above.

Now what i did is after coming out of the while loop i am again assigned those values which are to retured , then the program is working fine.

so is it compulsory to assign the variables to be returned by the function after while loop.

let me know about this


 
It sounds to me as if your while loop condition is never satisfied so when you run the metropolis function the output values are never assigned. Try using the debug functions in the Matlab editor. Alternatively, you can do the slightly cruder test of putting a line inside the while loop such as

disp('I am inside the while loop')

M

--
Dr Michael F Platten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top