Separate cell array and perform Gaussian fit

조회 수: 2 (최근 30일)
Nathan
Nathan 2016년 1월 11일
댓글: Star Strider 2016년 1월 12일
Hey everyone,
Please forgive me in advance if this is a trivial problem. I am not a matlab expert.
I have a set of data that is 36180x3. Every 180 rows, I need to fit a gaussian distribution to the data and record the c-parameter from the fit (x data is 2nd column, y data is 3rd column).
I am struggling to put together an i loop that would achieve this. Can someone help me with this?

답변 (1개)

Star Strider
Star Strider 2016년 1월 11일
편집: Star Strider 2016년 1월 11일
No problem is ‘trivial’, but some are easier than others!
I would use the reshape function:
M = randn(360, 3); % Create Data Matrix
Mr = reshape(M, [], fix(size(M,1)/180), 3); % Reshape
Q1 = M(1:5,:); % Check Original (Delete)
Q2 = squeeze(Mr(1:5,1,:)); % Check Results (Delete)
for k1 = 1:size(Mr,2)
prms{k1} = polyfit(Mr(:,k1,2), Mr(:,k1,3), 5); % Fit Data
end
I used polyfit here only to illustrate the procedure. I did not attempt to do a Gauss function fit.
  댓글 수: 2
Nathan
Nathan 2016년 1월 12일
Thank you for the answer! After some manipulation, I was able to get it to work for my script.
Thanks again!
Star Strider
Star Strider 2016년 1월 12일
My pleasure!
If my Answer helped you solve your problem, please Accept it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by