フィルターのクリア

How to pass Matlab workspace variable into system command?

16 ビュー (過去 30 日間)
Saurabh Srivastava
Saurabh Srivastava 2014 年 1 月 18 日
回答済み: cui,xingxing 2019 年 1 月 2 日
I am using a program (wgrib) which is used to read .grb file and it runs in linux environment. This program required filename to read it. Now I want to use this programm using 'system' command in matlab. It works fine when I give the name of file but fails to execute when I give the variable which contains several file name. For ex. it works fine when I use
[u v]=system('wgrib xyz.grb') where wgrib is programm and xyz.grb is file name
But when I give it like
[u v]=system('wgrib filename')
where filename is a matlab variable which contains file name (i.e. xyz,grb), it does not execute and says didn't find file.
Can anyone suggest how to pass matlab variable in system command.

採用された回答

Jan
Jan 2014 年 1 月 18 日
[u v] = system(['wgrib ', filename])
  1 件のコメント
Saurabh Srivastava
Saurabh Srivastava 2014 年 1 月 20 日
Dear Jan, Thanks for suggestion but I have already tried it and It did not work. :(

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2014 年 1 月 20 日
filename = 'xyz.grb';
[u v]=system( sprintf('wgrib %s', filename) )

cui,xingxing
cui,xingxing 2019 年 1 月 2 日
filename = 'xyz.grb';
command = ['wgrib ',filename];
[u v] = system(command)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by