필터 지우기
필터 지우기

Using a Matlab file as an input argument in a function ?

조회 수: 5 (최근 30일)
Gayan Lankeshwara
Gayan Lankeshwara 2020년 7월 23일
댓글: Gayan Lankeshwara 2020년 7월 23일
Assume that I have a sampledata.mat array and I have to input it into a function myfun.
I have defined the function as below.
function myout = myfun(mydataset)
dataset = load(mydataset) % is this correct way to use !
% code goes over here ...
end
Then I used the following syntax to execute myfun with corresponding arguments.
DataOut = myfun('sampledata.mat')
When I try to execute this, I am getting an error message saying,
Reference to a cleared variable mydataset !
(Note that I am working on the same directory where both myfun.m and sample.mat are in)
Can anyone please help to find what is wrong over here.
Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2020년 7월 23일
Delete the
clear
that you have in your function

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by