Numerical output from "fit" function using a loop

조회 수: 1 (최근 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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by