필터 지우기
필터 지우기

Vectorizing matrix fitting to a curve

조회 수: 5 (최근 30일)
carlos Uribe
carlos Uribe 2014년 3월 17일
답변: Dylan Marques 2019년 7월 5일
Hello,
I have three volume matrices A, B, C of 128x128x128 each.
A represents the data at t1 B represents the data at t2 C represents the data at t3
Now, I need to fit each corresponding voxel to a curve, so I'm using the fit function available in matlab
coefficients=fit(xdata,ydata,myfunction,options);
where
xdata=[t1,t2,t3]
and
ydata=[A(i,j,k),B(i,j,k),C(i,j,k)];
So the way I'm doing this right now is I have to loop through the 128x128x128 voxels of my matrices in order to obtain the fitting coefficients of the curve for each corresponding voxel at the different times and storing them in a cell:
for i=1:128
for j=1:128
for k=1:128
coefficients{i*j*k}=fit([t1,t2,t3],[A(i,j,k),B(i,j,k),C(i,j,k)],myfunction,options);
end
end
end
This is of course taking a very long time.
Is there a way of vectorizing this or at least making it more computational efficient?
I appreciate any help.
Thank you

답변 (2개)

HG
HG 2019년 5월 8일
Hi, I have an almost identical problem to the one described above. Did you find a solution to your problem?

Dylan Marques
Dylan Marques 2019년 7월 5일
Hi,
I am not aware of an easy solution for your question. A possible way of making it faster is to use parfor (https://uk.mathworks.com/help/parallel-computing/parfor.html) so that the for runs in multiple cores.
The faster solution is to make a vectorized version of fit. However this can be complicated to do and time consuming (your time, not the computer time). Which function are you trying to fit to your data?
Many thanks

카테고리

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