0

I have a MatLab function in which I have a for-loop that make a call in every iteration to an external function from a library.

Unfortunately this function produces a hundred lines of console output on every call and my for-loop (parfor to be precise) has a number of iterations in the order of 10k-100k!

So I am addressing basically 2 problems:

  • Output console is extremely confusing and hardly readable
  • A consistent (or near so) slow down in code execution

The first problem is the most annoying at the moment but I would like to solve both.

I am wondering if there is a way to prevent a function to produce text output.

vitokr
  • 87
  • 1
  • 1
  • 11
  • 1
    possible duplicate of [Suppressing a function's command window output](http://stackoverflow.com/questions/3029636/suppressing-a-functions-command-window-output) – Ander Biguri Jan 21 '15 at 10:43
  • 1
    In the end I used evalc as suggested in the other question and in this one by Daniel. The only problem was about evalc that cannot be used in parfor, so I wrapped my evalc in another function and all just worked fine. – vitokr Jan 21 '15 at 14:53

1 Answers1

2

There are two possibilities:

  1. You can create a private folder next to the function and place an empty function fprintf (or whatever is used to print) inside. This way you are overwriting the build-in function with a new one simply doing nothing.
  2. use evalc to run the function.
Daniel
  • 36,610
  • 3
  • 36
  • 69