Linear fit for a intensity plot (surface plot)
이전 댓글 표시
Hi,
I want to find the rotation angle of this plot. (Angle with respect to the horizontal axis.)

In order to do that I'm thinking of doing a linear fit and get the gradient. Something like this:

How can I do a linear fit to this surface plot?
Thank you.
댓글 수: 5
Mathieu NOE
2021년 3월 8일
hello
do you have the data or do you have only this picture ?
S
2021년 3월 8일
Mathieu NOE
2021년 3월 8일
So first attempt here .... but my linear fit seem a bit off
I smoothed first a bit the data and search for peak location at each row.
the red line is the line of maximum values , but visually it seems not truly aligned with our expectation

data = readmatrix('Rotation.txt');
[m,n] = size(data);
% [val,ind] = max(data,[],'all');
dataS = smooth2a(data,1,7);
x=0;
y=0;
k=0;
for ci = 15:40
k = k+1;
[val,ind] = max(dataS(ci,:));
x(k) = ind;
% zz= cumtrapz(dataS(ci,:));
% x(k) = interp1(zz,1:109,max(zz/2));
y(k) = ci;
end
figure(1),imagesc(dataS)
hold on
plot(x,y,'r')
hold off
axis('xy');
% axis('equal');
slope = mean(diff(y))./mean(diff(x));
angl = atan(slope) % in radians
Image Analyst
2021년 3월 8일
Unrecognized function or variable 'smooth2a'.
Error in test5 (line 14)
dataS = smooth2a(data,1,7);
S
2021년 3월 8일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Geographic Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
