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

4 次查看(过去 30 天)
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)

请先登录,再进行评论。

更多回答(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]');

类别

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