How would I write this code?

2 次查看(过去 30 天)
Amanda Viken
Amanda Viken 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