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!
