How to "silence" a Matlab function? [duplicate] - matlab

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Suppressing a function’s command window output
Suppress Output
Is there a way to "silence" the output of a Matlab function? In other words, if a function generates some displayed text in the command window, is there a way to run it in a quiet mode, where the output is suppressed?
In my case, I am using a third-party function iteratively that displays a lot of text, and I want to find a way to suppress that text without modifying the function itself. I'm thinking there must be some kind of wrapper function like quiet(thirdpartyFunction) that gives this kind of behavior. Or is this wishful thinking?

You can probably use evalc and discard the return value.

Related

Matlab: hide stout (no evalc)

I have read several posts here and in other forums to understand how to do hide the output of a function on the command window. Generally, the answer is: "use evalc".
Today I posted another question for a different issue (Memory issue with Matlab: update variable in .mat) and a user showed me why it is always better to avoid the usage of eval/evalc (How to put these images together?).
What if I want to avoid evalc but I want to hide the output of a function from the command windows? Is it possible to do it?
EDIT:
I don't think it is a duplicate.
As said in the introduction there are several posts (also here in stack overflow) that address this question. But (including the post which should be a duplicate of this question: Suppressing a function's command window output ) the main answer is to use evalc, which as written in the title, I don't want to use. Also, as written in the link above, using a private disp might be risky, it is not going to suppress outputs resulting from fprintf or from a missing semicolon (creating also a private fprintf would hide also some output string that I want to have).

Multiline anonymous function in Matlab? [duplicate]

This question already has answers here:
How to execute multiple statements in a MATLAB anonymous function?
(5 answers)
Closed 7 years ago.
Is it possible to create multiline anonymous function in Matlab?
There are no appropriate examples in documentation, but also no direct denials. In web discussions I found some derisions of askers as if it silly wish. Nowadays, when most languages introducing lambda expressions with multiline capability this looks strange.
No, unfortunately this is not possible.

Matlab compiler with special character string as input [duplicate]

This question already has answers here:
How to escape parameter in windows command line?
(3 answers)
Closed 7 years ago.
So I need to run my program in the windows prompt like this:
my_program somestring.
The problem is that somestring can contain characters like &.
I get problems like:
'si' is not recognized as an internal or external command.
Where 'si' is after & in the string.
I just want to read the whole string.
What can I do?
Edit: It seems to work if I put "" around somestring.
But this is not something I can control.
You seem to believe that this error is returned by matlab, however that is not the case.
This error is returned as a result of the command prompt being unable to run your command. As such we can conclude the following:
The string never reaches your matlab program
Changing your matlab code will not help in any way
You already seem to know how to solve it from the side of the input as was also decribed in How to escape parameter in windows command line?. But unfortunately the answer is that there does not appear to be another way.
Conclusion
If you enter an invalid string in the command prompt, there is nothing you can do in matlab to 'make it work'.

Name a variable as string in Matlab [duplicate]

This question already has answers here:
Create variables with names from strings
(6 answers)
Closed 7 years ago.
Assume the variable FileName contains a string such as Name1. How do I make a variable with the name Name1?
The example 4 at this page seems to be similar, but I cant get it to work. Is it the right way to do it?
http://se.mathworks.com/help/matlab/ref/genvarname.html
What you see in "Example 4" is accused as bad programming style. The documentation also contains a section why to avoid eval.
I would recommend a struct with dynamic field names to achieve similar.
filename='name1';
mydata=struct();
mydata.(genvarname(filename))=load(filename);
Besides better performance, you also get additional functionality when handling multiple files. For example structfun to apply a function to all your data or fieldnames to get all filenames.
For what you want to do, the eval function is there for you:
FileName = 'Name1';
eval([FileName ' = 18;']); % Executes "Name1 = 18;"
and now the variable Name1 is created and has a value of 18.
The function genvarname has a different purpose, which is to generate acceptable and non-conflicting variable names, and not the variables themselves.

How to open a file using matlab and change something in it automatically?

I need to open a software and give it a value and then execute it to obtain some results
but the problem is that I have many values and each time I put a value manually which is very time consuming. Is there a way to do this automatically with MATLAB?
First of all: your question title and your actual question are quite different. I'm going to give you ideas to answer your question, not your question title.
you need to find out, whether you can run your software in batch mode. That means, you need to be able to control the software from the command-line.
Once you know that, you can use the system command of matlab to run the cmd from your script.
for example:
system( 'mySoftware.exe' -myIndividualParameters )
If it's not possible to pass parameters to your software, it may can read text files, which you can create with matlab before.
Anyway, your question is specifying absolutely nothing. You have to give a lot more information: how is your software obtaining parameters? you can it be started? Which format do the parameters need? Do you want matlab to do something with results of your software?