When a function is invoked, how do you supress the "ans = ... " output? I have a semicolon on every single line in the function and yet I still get the "ans" output!

I wrote a MATLAB function that finds a root and then prints out the results to the command window using fprintf. After it is invoked in the main program, it prints out the results as it should and then, for some reason I don't understand, it prints an intermediate value of an array: ans = 2.3054666 2.599991 ... I have a semicolon at the end of every single line in the function and yet I still get the "ans" output! Can anyone explain how to suppress all output except for that which I specify in the function? Can this be done in MATLAB? Thanks

 Réponse acceptée

If you define a function to return something, and call it from the command line like
>> myfun(23)
it will return an ans. You can use
>> myfun(23);
If that does not solve your problem, it would be best to attach the function so that we can have a closer look.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by