필터 지우기
필터 지우기

Problem with time code - function definition not permitted in this context

조회 수: 1 (최근 30일)
CivilEngBath
CivilEngBath 2021년 1월 24일
답변: Star Strider 2021년 1월 24일
Hi, I'm having this problem with a code to find the maximum water discharge every month from a table. It keeps coming up with 'Function definitions are not permitted in this context'. What am I doing wrong?
function maxDischarges = MaximumDischarge(data, dischargeColumnIndex)
index_column=width(data)+1;
index=[1:length(data)].';
indexed_data=[data,index];
dates=datetime(indexed_data(:,4),indexed_data(:,3),indexed_data(:,2));
monthlyFlowMaximums = retime(timetable(dates,indexed_data),'monthly','max');
monthlyFlowMaximumsArray = table2array(monthlyFlowMaximums(:,1));
maxDischarges = monthlyFlowMaximumsArray(:, [dischargeColumnIndex, index_column]);
end

답변 (1개)

Star Strider
Star Strider 2021년 1월 24일
I have no idea what the rest of your script looks like, since it was not posted.
See the documentation on Create Functions in Files to create them correctly in the script you are using.
Also see Function Basics for a comprehensive overview.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by