Filter löschen
Filter löschen

Passing .dat files as function parameter

3 Ansichten (letzte 30 Tage)
UET Hussain
UET Hussain am 8 Feb. 2018
Kommentiert: UET Hussain am 8 Feb. 2018
Hi All, I want to create a function that takes two .dat files as input. The output is not required, as it will be only graphs. the function is:
function y = reAdfiLe(file1, file2)
load file1;
load file2; %loading two files
amp1 = file1(:,2);
amp2 = file2(:,2); %taking 2nd column of files
a = max(amp1);
as I call this function
>>reAdfiLe(myfile1,myfile2)
it gives error "Undefined function or variable 'myfile1'." just cannot understand whats the matter.
  2 Kommentare
Birdman
Birdman am 8 Feb. 2018
Share your file.
UET Hussain
UET Hussain am 8 Feb. 2018
cannot attach .dat file, hence attaching .xls format

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Feb. 2018
function y = reAdfiLe(file1, file2)
y = nan;
file1_data = load(file1);
file2_data = load(file2); %loading two files
amp1 = file1_data(:,2);
amp2 = file2_data(:,2); %taking 2nd column of files
a = max(amp1);
You would call this with
reAdfiLe('myfile1', 'myfile2')
  1 Kommentar
UET Hussain
UET Hussain am 8 Feb. 2018
Thanks Sir, function will be called as
reAdfiLe('myfile1.dat','myfile2.dat')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by