Determine the slope of experimental data

4 vues (au cours des 30 derniers jours)
Wissem-Eddine Khatla
Wissem-Eddine Khatla le 25 Mar 2021
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.

Réponses (1)

David Hill
David Hill le 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);
  1 commentaire
Wissem-Eddine Khatla
Wissem-Eddine Khatla le 25 Mar 2021
Thank you for your quick answer : in fact my question is incomplete. I have several curves like this to treat so that's why I was looking for a solution in order to obtain automatically the wanted result (that's why I was thinking about this potential trick using the slope).
Do you have a suggestion in order to do so ?
Thank you again

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by