Numerical output from "fit" function using a loop
13 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!