changing time from decimal days to +- 0 from high water

1 回表示 (過去 30 日間)
James Porter
James Porter 2015 年 3 月 13 日
コメント済み: James Porter 2015 年 3 月 19 日
I am attempting to plot pressure gradient over a tide cycle. I would like to change the time, currently in decimal days, into +- hours with high water as 0.
%find high water value pkIndex = max(pf)
%find time value at high tide timepkIndex = tf(pkIndex)
%I experience this error Attempted to access tf(1.8268); index must be a positive integer or logical.

採用された回答

David Young
David Young 2015 年 3 月 13 日
編集済み: David Young 2015 年 3 月 13 日
Guessing a bit, because you don't tell us what pf and tf are, but assuming they are water height and time vectors, I suspect that it may help to change the first line of code to
[~, pkindex] = max(pf);
This is because the first result from max (in this case 1.8268) is the maximum value stored in the vector pf. What you need is not, I think, that value, but the index at which it is stored, which is the second result from max.
  1 件のコメント
James Porter
James Porter 2015 年 3 月 19 日
Excellent, thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOceanography and Hydrology についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by