필터 지우기
필터 지우기

Loop data in both x and y direction, and do linear fit of each y at each x

조회 수: 5 (최근 30일)
I have two matrice. matrix 1 (time points) is 96 by 1 (row is time); matrix 2 is 96 by 150 (attached). matrix 2 is the readout MSD data points at each time point (row) of 150 individual particle (column). I want to fit each MSD data of each particle at increased time point to y=ax+b and so on until the last time point, to get the fitted slope (a). In this way, I can obtain the slope of each particle at increased time points and study their diffusion behavior.
For example: time point 1 has one MSD readout, time point 2 has two MSD readout, time point 3 has three MSD readout. Each of them will generate an x,y line and I wanna find out the fitted slope of the x,y line to y=ax+b.
The matrix 1 can be written as:
time = 15:15:1440; %matrix 1
The result is ideally to be a slope matrix (96 by 150). I have very limited clue on how to do it, appreaciate if anyone know how to do this.
  댓글 수: 5
Umar
Umar 2024년 7월 11일
Hi Yang,
Please see response from @Matt J, is this the solution you are seeking regarding your recent comment.
Thanks @Matt J for your contribution and sharing your knowledge, highly appreciated.
Yang Hu
Yang Hu 2024년 7월 11일
Hi Umar,
I upload actual data point called 'MSDdata' to be more specific. Each row is the readout MSD data at different time points, time interval is 15 - row 1 is the MSD readout at time 15, row 2 is the readout at time 30 and so on.
Row 1 and row 2 MSD data will generate a connected curve with respect to their time points, and this curve will be fitted to y=ax+b to obtain a fitted slope. Due to the data variation, this generated curve will have different slopes over time. I would like to fit y=ax+b to each indidivual particles at increased time points til the end, and continue for all particles.

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

채택된 답변

Matt J
Matt J 2024년 7월 11일
t = 15:15:1440; %time
MSD=readmatrix('MSDdata.xlsx');
A=t.'.^[1,0];
slopes=nan(size(MSD));
for i=1:height(A)
tmp=A(1:i,:)\MSD(1:i,:);
slopes(i,:)=tmp(1,:);
end
whos slopes
Name Size Bytes Class Attributes slopes 96x150 115200 double
  댓글 수: 4
Matt J
Matt J 2024년 7월 12일
Yes, Umar is right. That's what it does.

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

추가 답변 (1개)

Matt J
Matt J 2024년 7월 11일
편집: Matt J 2024년 7월 11일
Perhaps this is what you want.
matrix1=rand(96,1); matrix2=rand(96,150);
[Xslope,Tslope]=gradient(matrix2,1:150,matrix1);
whos Xslope Tslope
Name Size Bytes Class Attributes Tslope 96x150 115200 double Xslope 96x150 115200 double
  댓글 수: 1
Yang Hu
Yang Hu 2024년 7월 11일
Hi Matt, thank you for your response. I updated how the data actually are. I want to fit matrix2 (now called MSD data) to increased time points, not the individual time point they are at. For example, MSD data at time point 5 will generate a x,y line with MSD data from time point 1 to 5 at increased time interval (15). So I want to fit this x,y line at increased time points to y=ax+b individually.

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

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by