How would I write this code?

조회 수: 3 (최근 30일)
Amanda Viken
Amanda Viken 2021년 10월 13일
답변: Cris LaPierre 2021년 10월 13일
I have data like this:
Fourth column is time in UTC/Zulu and the fifth column is stage observations.
1 1 2015 0 3.48
1 1 2015 6 3.48
1 1 2015 12 3.46
1 1 2015 18 3.43
1 2 2015 0 3.39
1 2 2015 6 3.33
1 2 2015 12 3.27
1 2 2015 18 3.21
I am trying to use the find function to index the data correctly.
This is what I have so far but I keep getting errors.
ind = find((obs(:,1)== month) & (obs(:,2) == day) & (obs(:,3) == year) & (obs(:,4) == time));
These are the errors that continue to pop up.
>> COMO2_2015
Error using month (line 44)
Please enter D.
Error in COMO2_2015 (line 5)
ind = find((obs(:,1)== month) & (obs(:,2) == day) & (obs(:,3) == year) &
(obs(:,4) == time));

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 10월 13일
What is month?
You are using it as a variable. However, if you have not defined it as a variable, then MATLAB is trying to call the month function. However, doing so without inputs will result in this error.
t = datetime('now')
t = datetime
13-Oct-2021 21:09:06
month(t)
ans = 10
% the error you are seeing due to calling the function without inputs
month
Error using month (line 44)
Please enter D.

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by