Determine the slope of experimental data

조회 수: 5 (최근 30일)
Wissem-Eddine Khatla
Wissem-Eddine Khatla 2021년 3월 25일
댓글: Wissem-Eddine Khatla 2021년 3월 25일
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.

답변 (1개)

David Hill
David Hill 2021년 3월 25일
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
Wissem-Eddine Khatla
Wissem-Eddine Khatla 2021년 3월 25일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by