Previous in Forum: Need EarthLink Help - Part 2   Next in Forum: Multi-touch Technology Monitor Software
Close
Close
Close
4 comments
Rate Comments: Nested
Commentator

Join Date: Aug 2013
Posts: 62

Error About Unassigned Output Argument in Matlab

08/26/2013 2:59 PM

I have created a function to define an array (matrix_vor.m). That function I am calling in another in another file (trial_3.m).

I get an error regarding the output argument not being assigned.

1. Why I get such an error?

2. How to rectify it?

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru

Join Date: Mar 2007
Location: by the beach in Florida
Posts: 33392
Good Answers: 1817
#1

Re: Error about un assigned output argument in Matlab

08/26/2013 5:42 PM

" Explanation:

One of the functions you have called is defined to return an output argument but that output argument does not exist in the function when it tries to return.


Common causes:

You have misspelled the name of one of your output arguments inside your function, or you have forgotten to assign a value to one of the output arguments of your function. Alternatively, the function was originally written with one or more output arguments, but the section of the function that computed the output argument was removed or modified in such a way that the output argument is now extraneous.


Solution:

Stop MATLAB on the last line of the function listed in the warning or error message. Verify that each of the output arguments listed in the function declaration line at the beginning of the function exist after that last line is executed (using the DBSTEP function or the Step button in the Editor). If the arguments do not exist, examine the function to determine where you intended the arguments to be declared. Verify that those lines of code are being executed and have no typographical errors."

http://www.mathworks.com/support/solutions/en/data/1-FA99V6/index.html

__________________
All living things seek to control their own destiny....this is the purpose of life
Register to Reply Score 1 for Good Answer
Commentator

Join Date: Aug 2013
Posts: 62
#2
In reply to #1

Re: Error about un assigned output argument in Matlab

08/26/2013 10:52 PM

I had found the link mentioned by you. But I could not solve the problem using that. Please refer to the images shown above. The first one shows the output window of matlab. The second is the function that i calls the matrix_vor function. The third image is the matrix_vor function file.

Please, let me know the error in them, and the rectification for it.

Register to Reply
Commentator

Join Date: Aug 2013
Posts: 62
#3
In reply to #2

Re: Error about un assigned output argument in Matlab

08/26/2013 11:54 PM

Well I did another experimentation:

I found out this-

The output of the first called function are not being passed as input to the second called function. I mean the output of input_val are not being passed to matrix_vor. In basic c-language we need to define the variables as global variables to achieve such thing. What do we need to do in MATLAB?

Register to Reply
Participant

Join Date: Aug 2013
Posts: 1
#4

Re: Error About Unassigned Output Argument in Matlab

08/27/2013 5:03 AM

Hi dreamz,

This error is quite straightforward.The for-loop (i=1:m) you defined, is only entered correctly if m >= 1. If m <1, the function does NOT enter the for-loop, and therefore does not assign your d-variable, thus gives an error instead.

If m can/may be smaller than 1, this can be circumvented by adding following code to your matrix_vor function:

<code>

if ~exist('d') d=[]; end

</code>

PS: You can even write this function in one line (including the solution) by using:

<code> d(1:m) = 0.5* ones(m,1); </code>

Kind regards,
Ryton

Register to Reply Score 1 for Good Answer
Register to Reply 4 comments

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

dreamz (2); Ryton (1); SolarEagle (1)

Previous in Forum: Need EarthLink Help - Part 2   Next in Forum: Multi-touch Technology Monitor Software

Advertisement