Effacer les filtres
Effacer les filtres

save the output of system command using matlab

18 vues (au cours des 30 derniers jours)
Ano
Ano le 28 Nov 2016
Commenté : Jan le 29 Nov 2016
Hello! I am executing a system command via matlab. in the command I am writing the output to a file. when running the code I can find the generated file but I want that file be passed to Matlab as a variable, how can I get to this ? see the code bellow (I want something so that fileA.txt be attributed to cmdout or any thing similar so Matlab can recognize and work directly with the file)
command = 'MyInstuction >fileA.txt';
[status,cmdout] = system(command);

Réponse acceptée

Steven Lord
Steven Lord le 29 Nov 2016
Use concatenation or sprintf to assemble a command for use with the system function that needs to include information from a variable.
myfilename = 'fileA.txt';
command = ['MyInstuction > ' myfilename]
% I left off the semicolon on the previous line deliberately
% so you can see the command to be executed
[status,cmdout] = system(command);

Plus de réponses (2)

Walter Roberson
Walter Roberson le 28 Nov 2016
Leave off the redirection. Just
command = 'MyInstuction';
[status,cmdout] = system(command);

Ano
Ano le 29 Nov 2016
thank you for your reply!
  • I have made the change that you have suggested . it takes a long time since the generated file is very large. any other alternatives ??!!
  • I get cmdout as a 'char', how can I extract my data from it or how can I know where my data is placed in cmdout?Best regards!
  3 commentaires
Ano
Ano le 29 Nov 2016
thank you Jan Simon, I posted the comment as an answer because there is no notification for comments and the time response is really very critical!
Jan
Jan le 29 Nov 2016
If the repsonse is time critical, please answer my questions for clarifications. I'd really like to assist you, but I cannot guess, "how can I know where my data is placed".

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by