Files as Input Arguments for a Function

I want to define a function that takes two files (containing data vectors) and two constants as input arguments.
How can I do this?
Thanks, Mika

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2011 年 10 月 14 日

0 投票

The char variable can be used to contain the file name string.
function out=MyFunction(FileName1,FileName2,Const1,Const2)
sprintf('File 1 is %s\n',FileName1);
sprintf('File 2 is %s\n',FileName2);
Out=Const1+Const2;
Call it this way,
Out=MyFunction('mydata.mat','otherdata.mat',1,2)

カテゴリ

質問済み:

2011 年 10 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by