필터 지우기
필터 지우기

Passing .dat files as function parameter

조회 수: 2 (최근 30일)
UET Hussain
UET Hussain 2018년 2월 8일
댓글: UET Hussain 2018년 2월 8일
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
Birdman
Birdman 2018년 2월 8일
Share your file.
UET Hussain
UET Hussain 2018년 2월 8일
cannot attach .dat file, hence attaching .xls format

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 8일
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
UET Hussain
UET Hussain 2018년 2월 8일
Thanks Sir, function will be called as
reAdfiLe('myfile1.dat','myfile2.dat')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by