Effacer les filtres
Effacer les filtres

Confuse on while and for loop with interval that starts with 0

1 vue (au cours des 30 derniers jours)
EricLui
EricLui le 5 Jan 2012
Hello fellas, i guess i need some help for my class work.
I have to write a MATLAB script that compute the required force to lift an object, with a rope pulled across a fixed cylinder.
Here are the given information
T1 is the weight of object in Newton.
A is the degree traveled
CF is the coefficient of friction
T1=500N A=[0,720] CF=0.3
Here is the script that i have
%This program will compute the force required to lift the weight across the
%pulley from 0 to 720 degrees, and plot it as a graph.
clear %clear workspaces
clc %clears command window
T1= input('Weight of the object in Newton');
CF= input('Coefficient of friction');
Np=input ('Spacing of A points in DEG');
A=1:Np:720;
for K=1:length(A)
B=CF*A;
T2=T1*(exp(B));
while A<1
T2=T1
end
end
plot(A,T2)
title('Degree vs required force')
xlabel('Degree')
ylabel('Required force')
grid
Here is my question. What should i do in order to show the angle 0 in the graph too? I tried to start with 0, but MATLAB said it must be positive real integer. The forces are extremely large, and it doesn't show very clearly in the graph. Is there anyway to scale the graph, and show the information more clear?
One last question. how do i use the fsprintf to show the answer of angle 0?
Please help! I am confused! thanks for people who are trying to help me!

Réponse acceptée

Rick Rosson
Rick Rosson le 5 Jan 2012
Please try:
A = 0:Np:720-Np;
HTH.
Rick

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by