How to place a value in a function

Hello,
I wrote down a code and I want to place F_x(theta=60) to get the answer . How to do it.
Thanks for the helpers and Happy New Year :)
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' )
ylim([0 350])
grid on
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('theta [deg]');
ylabel('Force [N]');
F_x(theta=60) =?? %%%%%%%% Here help

 Accepted Answer

F_x is an array, not a function (in the MATLAB sense: https://www.mathworks.com/help/matlab/function-basics.html)
To access elements of an array you can use simple logical indexing:
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' )
ylim([0 350])
grid on
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('theta [deg]');
ylabel('Force [N]');
F_x(theta==60)
ans = 0

5 Comments

Thank you :)
I tried to place it and it came out logistical and not valuable.
Theta_swept=Theta_Exit-Theta_Entrance
F_x_angle_swept=F_x(theta==Theta_swept)
theta = 61.2;
theta_down = floor(theta);
theta_up = ceil(theta);
index_down = theta_down + 1;
index_up = theta_up + 1;
F_x_theta = F_x(index_down)*(theta-theta_down) + ...
F_x(index_up)*(theta_up-theta)
F_y_theta = F_y(index_down)*(theta-theta_down) + ...
F_y(index_up)*(theta_up-theta)
F_theta = F(index_down)*(theta-theta_down) + ...
F(index_up)*(theta_up-theta)
I did not do well, gave an answer that
F_x_theta =1.8199e-12
Torsten
Torsten on 31 Dec 2021
Edited: Torsten on 31 Dec 2021
It's the correct result since you set F_x, F_y and F to zero for 60 <= theta <=89.
And 1.8199e-12 is zero (numerically).

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 31 Dec 2021

Edited:

on 31 Dec 2021

Community Treasure Hunt

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

Start Hunting!