Reputation: 15
very good day all,
I am new to matlab, I am not familiar with most of the matlab function guys and wish can get some tips from you..
The problem is I want one of the system function to be executed. More precisely, I ask a user to input a string and I want to pass this string to my function that executes the string and return to me the output
for instance
input: dog
pass the dog to !wn
The function should be in this form !wn dog 'parameter'
. Executable function. I want to execute this function not return me the !wn dog 'parameter'
. In matlabe command it is working if i use the system function and then use this
>> !wn dog param
the above command is working in the command environment but if i want an input from a user and put the input into that function and execute it and i expect the output to be like. Just want to know how to make it executable from a mat file
I tried to do this
keyword= 'dog'; %
x = system('wn'); % this to execute the system function
output= strcat('!wn', keyword)
Your kind answer is highly appreciated.
Thank you
Upvotes: 0
Views: 143
Reputation: 18484
I'm not sure if the !
form of calling system functions is going to work in your case. It seems to be designed mainly as a shortcut to be used in the command window and provides no means of capturing output. However, you can use the system
function like this:
[~,result] = system(['wn ' input ' ' params]);
or you can generalize it a bit and turn it into a function:
function result=call_wn(input,varargin)
[status,result] = system(['wn ' input sprintf(' %s',varargin{:})]);
This allows a variable number of parameters, including none. input
is required. I'm guessing that you're on Windows (I have no idea what the "wn" command is), so also check out dos
.
Upvotes: 1