Numerical output from "fit" function using a loop

10 ビュー (過去 30 日間)
Kevin Simans
Kevin Simans 2017 年 2 月 23 日
コメント済み: Rik 2017 年 2 月 23 日
Hello folks,
I have a matrix of water velocity data called ur10 (43x609), where there are 609 profiles at regular time intervals and 43 vertical depth bins per profile. I want to fit an exponential curve to the lowermost 4 bins of each profile, then pull out the coefficients (i.e. slope and y-intercept, here ustar and z0) of each line. My end goal is then to have two vectors, each 609 long, with all the slopes and y-intercepts. My code is below, but when I run it I get an error stating "Error using cfit/subsref. Too many output arguments." What do I need to change? I haven't used the "fit" function before so any advice would be much appreciated. I am using Matlab R2016b on a Macbook Pro. Thanks!
fitcoeffs=zeros(609,2);z0=zeros(609,1);ustar=zeros(609,1);
for i=1:609 %first 609 profiles go to z bin 41
%calculate ustar using lowest 4 z bins
[fit,gfit]=fit(ur10(38:41,i),z(38:41),'exp1');
fitcoeffs(i)=coeffvalues(fit);
z0(i)=fitcoeffs(i,1);
ustar(i)=fitcoeffs(i,2);
end
  1 件のコメント
Rik
Rik 2017 年 2 月 23 日
Please copy the entire error stack.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by