Plot problem though there are data numbers

조회 수: 1 (최근 30일)
Emilia
Emilia 2021년 12월 30일
댓글: Emilia 2021년 12월 30일
Hello,
I made code in Matlab to produce a plot like in this picture. Although there are numbers but the graph does not work.
Thanks for the helpers and Happy New Year :)
K_t=750;
K_r=250;
b=5;
f_z=0.1;
time=0:0.008 ;
for i = 1: length(time)
t2 = mod(time(i), 0.002);
if (t2 >= 0.00134 & t2 <= 0.002)
F_x(i)=0;
F_y(i)=0;
F(i)=0;
else
st2 = sind(t2);
ct2 = cosd(t2);
h_cut = f_z * st2;
F_r=K_r*b*h_cut;
F_t=K_t*b*h_cut;
F_x(i) = -F_t .* ct2 + F_r .* st2;
F_y(i) = F_t .* st2 + F_r .* ct2;
F(i)=sqrt((F_x(i)).^2+(F_y(i)).^2);
end
end
plot(time,F_x,'--r',time,F_y,'--b',time,F,'k' )
legend('F_x' ,'F_y','F')
title('The components of the forces as a function of the angle of chip in the Up milling');
xlabel('Time [Seconds]');
ylabel('Force [N]');

채택된 답변

Voss
Voss 2021년 12월 30일
The reason the graph appears empty is because time=0:0.008 is a vector with only one element (0). What you need to do is specify a step-size, like time=0:0.00001:0.008, which is a vector that starts at 0 and goes to 0.008 in steps of 0.00001. (If you don't specify a step-size, the default step-size of 1 is used, which is not useful when the maximum value is 0.008.) Here's what you get with that time vector:
K_t=750;
K_r=250;
b=5;
f_z=0.1;
% time=0:0.008 ;
time=0:0.00001:0.008 ;
for i = 1: length(time)
t2 = mod(time(i), 0.002);
if (t2 >= 0.00134 & t2 <= 0.002)
F_x(i)=0;
F_y(i)=0;
F(i)=0;
else
st2 = sind(t2);
ct2 = cosd(t2);
h_cut = f_z * st2;
F_r=K_r*b*h_cut;
F_t=K_t*b*h_cut;
F_x(i) = -F_t .* ct2 + F_r .* st2;
F_y(i) = F_t .* st2 + F_r .* ct2;
F(i)=sqrt((F_x(i)).^2+(F_y(i)).^2);
end
end
plot(time,F_x,'--r',time,F_y,'--b',time,F,'k' )
legend('F_x' ,'F_y','F')
title('The components of the forces as a function of the angle of chip in the Up milling');
xlabel('Time [Seconds]');
ylabel('Force [N]');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by