How to do a cycle in the graph each time of plot

조회 수: 4 (최근 30일)
Emilia
Emilia 2021년 12월 25일
댓글: DGM 2021년 12월 25일
Hello :)
How to make a cyclic graph every time the same data start at a certain point as in the first mode just subtract the original.
Or have a special code offer for it.
I want similar as in the picture here.
For example, at theta= 90 I want to start as original at angle 0 to all calculations. In this case need to subtract 90 each time.
Too after theta= 180 subtract 180 each time.
Thanks for the helpers
clc;
clear;
K_t=750;
K_r=250;
b=5;
f_z=0.1;
theta=0:360 ;
for i = 1: length(theta)
if (theta(i) >= 60 & theta(i) <= 90) || (theta(i) >= 150 & theta(i) <= 180) || (theta(i) >= 240 & theta(i) <= 270)
F_x(i)=0;
F_y(i)=0;
F(i)=0;
else
h_cut=f_z*sin(theta(i)*pi/180);
F_r=K_r*b*h_cut;
F_t=K_t*b*h_cut;
F_x(i)=abs(-F_t.*cos(theta(i).*pi/180)-F_r.*sin(theta(i).*pi/180));
F_y(i)=F_t.*sin(theta(i).*pi/180)-F_r.*cos(theta(i).*pi/180);
F(i)=sqrt((F_x(i)).^2+(F_y(i)).^2);
end
end
plot(theta,F_x,'--r',theta,F_y,'--b',theta,F,'k' )
legend('F_x' ,'F_y','F')
title('The components of the forces as a function of the angle of chip in the milling');
xlabel('theta [deg]');
ylabel('Force [N]');

채택된 답변

Walter Roberson
Walter Roberson 2021년 12월 25일
K_t=750;
K_r=250;
b=5;
f_z=0.1;
theta=0:360 ;
for i = 1: length(theta)
t90 = mod(theta(i), 90);
if (t90 >= 60 & t90 <= 90)
F_x(i)=0;
F_y(i)=0;
F(i)=0;
else
st90 = sind(t90);
ct90 = cosd(t90);
h_cut = f_z * st90;
F_r=K_r*b*h_cut;
F_t=K_t*b*h_cut;
F_x(i) = abs(-F_t .* ct90 - F_r .* st90);
F_y(i) = F_t .* st90 - F_r .* ct90;
F(i)=sqrt((F_x(i)).^2+(F_y(i)).^2);
end
end
plot(theta,F_x,'--r',theta,F_y,'--b',theta,F,'k' )
legend('F_x' ,'F_y','F')
title('The components of the forces as a function of the angle of chip in the milling');
xlabel('theta [deg]');
ylabel('Force [N]');
  댓글 수: 2
Emilia
Emilia 2021년 12월 25일
Thank you!
A small question, how make a positive y-axis limit so that it is on a zero axis as in the picture. (Without -50)
DGM
DGM 2021년 12월 25일
You can just use
ylim([0 350])

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

추가 답변 (1개)

DGM
DGM 2021년 12월 25일
편집: DGM 2021년 12월 25일
You can use mod() and simple masking to avoid the loop and conditional.
K_t = 750;
K_r = 250;
b = 5;
f_z = 0.1;
theta = 0:360;
qtcycle = mod(theta,90);
sqc = sind(qtcycle);
cqc = cosd(qtcycle);
mask = qtcycle<=60;
h_cut = f_z*sin(qtcycle*pi/180);
F_r = K_r*b*h_cut;
F_t = K_t*b*h_cut;
F_x = abs(-F_t.*cqc - F_r.*sqc).*mask;
F_y = (F_t.*sqc - F_r.*cqc).*mask;
F = sqrt(F_x.^2 + F_y.^2).*mask;
plot(theta,F_x,'--r',theta,F_y,'--b',theta,F,'k' )
legend('F_x' ,'F_y','F')
title('The components of the forces as a function of the angle of chip in the milling');
xlabel('theta [deg]');
ylabel('Force [N]');
  댓글 수: 2
Emilia
Emilia 2021년 12월 25일
Thank you :)
Walter Roberson
Walter Roberson 2021년 12월 25일
ylim([0 350])
Note however that your F_y values to go about -10.4

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by