Variable number of output arguments in a function
Show older comments
Hi guys. I'm sorry if this is a basic question but I'm stuck. I have a function that I need to keep very general, since it's attached to a switch menu where I test three different structural elements from three differents POV (frontal, crest, back) using another switch menu. The problem is that I need to detect colors, but colors change in type AND also in quantity. Being the max number 3, I have a problem in the crest where I just have one color. The best way would be to 'mute' the variables of the other 2 colors but how do I do it? If I put [] the program crashes. Basically sometimes I don't need to use all the variables and I need them not to interfer with the rest of the code.
Answers (1)
10 Comments
giacomo
on 28 Sep 2017
it doesn't work
Your question and the details you've given are far too generic for us to know why it doesn't work, whatever it is
The problem is that the program still looks for...
The program does exactly what you wrote it to do, nothing less, nothing more. If it doesn't do what you want, then change it to do what you want. Unfortunately, as you've given so little details how anything is implemented, I don't see how we can give you more advice.
giacomo
on 28 Sep 2017
Adam
on 28 Sep 2017
Your question is about a variable number of input arguments, but your function has no input arguments at all.
giacomo
on 28 Sep 2017
Jan
on 28 Sep 2017
"A function like ..." is not useful. Obviously the details matter and your rough pseudo-code does not contain the details. This is completely unclear:
case 2 -> I set and use only 3 variables -> crashes
case 3 -> see case2 -> crashes
Please post the real code.
giacomo
on 28 Sep 2017
Jan
on 28 Sep 2017
I'm astonished. What are "those" variables? You "tried to comment the ones I didn't need"? Where? I do not see commented variables. Therefore I still cannot guess, what the problem is.
Come on, giacomo, we want to help you. Really. So post the failing code and explain exactly, what is failing: show us the complete copy of the error message or explain the difference between your expectations and the result. Which code causes which problem? As long as you keep this information as a secret, we cannot help you to solve the problem.
giacomo
on 28 Sep 2017
giacomo
on 4 Oct 2017
Categories
Find more on Model Compatibility 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!