# In Matlab, how can I write this script with a for loop and function?

1 view (last 30 days)
Nolyn Steffey on 8 Apr 2015
THE PROBLEM
Write a Matlab script to plot the force equation in Problem 5.16 on Page 193. Use the constants in the problem. Plot T2 vs the angle (in degrees). Plot the force required to lift the weight, versus the angle in degrees from 0
to the maximum angle supplied by the user, using = 0.3 (coefficient of friction). and 500 for T1.
The program asks for the maximum angle in degrees, then plots the force vs. angle using the plot and fplot functions:
Enter maximum value in degrees for x: 720
THE REQUIREMENTS
The equation is put in a function. The function is called in the loop that creates the x and y arrays for the plot command. It is passed the x value, and returns the y value of the equation. The function is also called by the fplot command. Note that the equation requires the angle in radians, however the user is asked for the angle in degrees, and the x axis is in degrees.
When the program is executed, the graph of the fplot command is in Figure 1, the graph of the plot command is in Figure 2.
MY WORK
close all;
T1=500;
u=0.3;
for i=0:length(degrees)
B=u*degrees;
T2=T1*(exp(B));
while degrees<1
T2=T1
end
end
plot (degrees,T2)