Thank you I actually don't understand what you're trying to do in each branch. I hope you can help me. I removed the -1 and it was able to work but I then run into the next issue. If either if is never true or if for some reason the loop never executes then gesture won't exist. Therefore, what is the point in increasing o or m or n , for that matter why do the variable names change depending on the branch at the end of the branch.
The adjusted code would still be flawed for for example something -3 , but the point is still easy to see: that the conditions associated with while or if can make real differences as to whether your code happens to assign to a particular variable or not. Are you certain that the condition is true? For some reason Matlab would rather give me this error than tell me I made a mistake. In my experience this means I made a mistake in my function. For example the conditions are if h is greater than 25000 than T will be a separate value, if h is between 11000 and 25000 then T will be a different value and so on. I am not sure if this will help anyone but know if you have satisfied the first condition the reason its not working is most likely due to Matlab stupidity and you need to make some sort of correction Matlab is unwilling to tell you about.
It also works and plays well with vectors, and avoids the complexity of if blocks. I don't know why the code not working. If the arguments do not exist, examine the function to determine where you intended the arguments to be declared. The problem is in the function CritPt itself: You need to assign a value to the variable cr. I don'y know what I'm missing. If the assumption is that none of the above should ever happen then the first thing your code should do is check that the input conforms to these assumptions and error otherwise. In that specific case find the statement you would expect it to fall into and see why it is not doing.
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. For example if you only pass in 1 column of train data then size train, 2 would be 1 and you subtract 1 from that to get the upper bound on the for loop, which would give you for from 1:0 which would not execute any iterations. Either add an else to the bottom of the if-else statement with some default value or initialise it before the if statement or check through every single if-else condition and work out what is falling through the gaps. Given that your function body is entirely one massive if-elseif statement with no else at the end this would seem to imply that the union of all your logical cases in your statement does not cover every possibility so it fails every test and just drops through to the end of the function without setting y to anything. Any help would be greatly appreciated You're using the function properly in the command window. I tried it and it worked! I have a function that Finds the Critical Points of a function.
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. I hope you can help me. So how can I set it so that it works for several values of V? A branch is only ever going to be run once on each invocation of your function. That assignment to gesture is deep inside an if inside a for loop inside another if. When the function completes, it attempts to return the value of whatever variable you have listed after function, but if that variable is not present you get an error.
Can it be set so that if I enter V as different values then I can get different T values? The variable disappear at the end of the function and is going to be equal to 1 the next time the function is called. I have updated my code to do the following:. I am trying to do a 1 nearest neighbor logic with a feature search function. Verify that those lines of code are being executed and have no typographical errors. . That kind of situation is typically better handled by using error.
Or is that not possible for Mat Lab. I find this extremely frustrating because there is no way to know what is wrong. It is not uncommon to encounter this kind of problem in situations in which you are checking the input arguments and if you find a problem then you return an error status in one of the arguments and then return, not having assigned to the other output arguments. . . . .
. . . . .
. . . . .