Linear fit for a intensity plot (surface plot)
Afficher commentaires plus anciens
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 commentaires
Mathieu NOE
le 8 Mar 2021
hello
do you have the data or do you have only this picture ?
S
le 8 Mar 2021
Mathieu NOE
le 8 Mar 2021
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
le 8 Mar 2021
Unrecognized function or variable 'smooth2a'.
Error in test5 (line 14)
dataS = smooth2a(data,1,7);
S
le 8 Mar 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Geographic Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
