このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
潮汐深度の予測
この例では、オックウェイ湾での潮汐深度を予測する方法を説明します。潮汐深度を予測することは重要です。水の深さがわからない場合、船は容易に浅い湾の底泥で動けなくなることがあります。
メモ
この例を実行するには、System Identification Toolbox を使用するライセンスの与えられた MathWorks アカウントにログインしていなければなりません。
オックウェイ湾のリアルタイム潮汐ゲージからのデータの読み取り
ThingSpeak™ のチャネル 50289 には、オックウェイ湾の潮汐深度に関するデータが含まれています。データは 5 分ごとに収集されます。チャネルの Field 1 には潮汐深度のデータが含まれています。
関数 thingSpeakRead
を使用して、特定の日 (たとえば、2016 年 7 月 1 日) のデータをチャネル 50289 から読み取ります。
メモ
この例は、AR モデルを使用して潮汐レベルなどの正弦波関数を近似する方法を説明するように設計されています。この例は、高度な潮汐予測技術の代わりとして設計されているわけではありません。測定された潮汐データを使用して潮汐レベルを予測する MATLAB® 関数、たとえば関数 UTide は、MATLAB Central で利用できます。
startDate = datetime(2016,07,01,0,0,0); endDate = datetime(2016,07,02,0,0,0); dateRange = startDate:endDate; data = thingSpeakRead(50289,'DateRange',dateRange,'Fields',1);
AR モデルによるデータの近似
関数 iddata
を使用して、潮汐深度データの iddata
オブジェクトを作成します。潮汐データはゼロ平均ではないため、データがゼロ平均になるようにデータのトレンド除去を行います。潮汐深度は時間と共に変化するため、関数 ar
を使用して、離散時間の自己回帰モデルでデータを近似します。
sampleTime = 5; IDdata = iddata(data,[],sampleTime,'OutputName',{'Tidal Depth'},'TimeUnit','minutes')
IDdata = Time domain data set with 288 samples. Sample time: 5 minutes Outputs Unit (if specified) Tidal Depth
% Capture the offest before detrending trend = getTrend(IDdata,0); % Detrend the data to zero mean IDdata = detrend(IDdata,0); modelOrder = 8; % Fit an AR model to represent the system sys = ar(IDdata,modelOrder);
潮汐深度の予測
関数 forecast
を使用して、翌日の潮汐深度を予測します。測定された潮汐深度のデータが 5 分ごとに更新されるため、予測データのサンプル数を 288 に設定します。
numSamples = 288; % yf is the forecasted model response, and yf_sd is the standard deviation of the output. % x0 is the estimated value for initial states, and sysf is the forecasting state-space model. % Also returned are the state trajectory, x, and standard deviation of the trajectory, x_sd [yf,x0,sysf,yf_sd,x,x_sd] = forecast(sys,IDdata,numSamples); % Retrend data before plotting IDdata = retrend(IDdata,trend); yf = retrend(yf,trend);
予測された応答のプロット
予測された潮汐データと共に測定データをプロットします。
figure; UpperBound = iddata(yf.OutputData+1*yf_sd,[],yf.Ts,'Tstart',yf.Tstart,'TimeUnit','minutes'); LowerBound = iddata(yf.OutputData-1*yf_sd,[],yf.Ts,'Tstart',yf.Tstart,'TimeUnit','minutes'); plot(IDdata(:,:,[]),'r',yf(:,:,[]),'b'); hold on % Plot also the 1-std deviation of uncertainties of the forecasted model plot(UpperBound,'k--',LowerBound,'k--'); legend({'measured','forecasted','1 sd uncertainty'},'Location','best'); xlabel('Time'); ylabel('Tidal depth (inches)'); title('Measured and Forecasted Tidal Wave Depths');
このプロットは、測定された応答および予測システムの応答を、標準偏差 1 の不確かさの範囲と共に示しています。