input variable when running bash within MATLAB

I am running some bash commands in a MATLAB function in order to process a text file before some analysis in MATLAB. I do not know how to take the name of the input file and use it within the bash command. What I mean is the following:
function [tt,value]=readfile(filename.txt,type); !grep TEXT filename.txt > FOO . . .
how can I use filename.txt as an input into the bash command?
Many thanks, CO

回答 (1 件)

Jan
Jan 2012 年 7 月 12 日
編集済み: Jan 2012 年 7 月 12 日

0 投票

function [tt,value] = readfile(FileName, type);
system(['grep TEXT ', FileName, ' > FOO . . .'])
Now call this as:
[tt, value] = readfile('filename.txt', type)
or
FileName = 'filename.txt';
[tt, value] = readfile(FileName, type)
Please consider that type is a builtin Matlab command, such that its name should be avoided for user-defined variables.

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

質問済み:

2012 年 7 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by