Determine the slope of experimental data
4 views (last 30 days)
Show older comments
Hello everyone,
I wrote a code in order to extract the value of the pitch angle of an helicoidal structure as a function of the height. The code is based on the data situated in the file "largeur.mat" that is attached to my post.
Here is the code :
clear all
path = rdir('10V\largeur.mat');
load(path{1});
%% We define the spatial scaling
% We hav a picture (echelle.tiff) that tells us 10cm=565pix
echelle=565/.1; %(pixel per meter). It's the equivalent of a frequency.
hauteur=[1:size(largeur,1)]/echelle;
for t = 1:size(largeur,2)
signal_spatial=largeur(:,t)/echelle;
signal_spatial=(signal_spatial-min(signal_spatial));
radius = max(signal_spatial); % The radius is considered as the largest region of the ribbon.
theta(:,t)=acos(signal_spatial/radius); % theta = acos(x/R)
end
plot(hauteur(30:218),theta(30:218,401))
%hold on
%plot(hauteur(30:218),pi-theta(30:218,401))
xlabel('hauteur');
ylabel('\theta');
I obtain the plot nammed "theta2" as a result (attached to my post); and if I add the line
plot(hauteur(30:218),pi-theta(30:218,401))
I obtain something like this :

Basically, what I am trying to do is to select the "linear" part of these two plots in order to have the evolution of the angle theta : it corresponds to the first "increasing" branch of the red plot and the second "increasing" branch of the blue one. We end up with a kind of straight line from -1.5 to 1.5.
I don't know how to do so : I was trying to calculate the slope, let's say for the red plot, and when the slope starts to become very small or 0 then we "jump" to the blue plot but I failed to do it...
Could someone take the time to explain me how to resolve this situation please ?
Thank you in advance,
Kind regards.
0 Comments
Answers (1)
David Hill
on 25 Mar 2021
Just select the data you want.
x=[hauteur(30:100),hauteur(130:218)];%assuming row array
y=[theta(30:100,401),pi-theta(130:218,401)];
p=polyfit(x',y',1);
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!