フィルターのクリア

How can i make this loop start at theta= zero and evaluate the same equations for values increasing by two (e.i at 0,2,4,6 etc.)

2 ビュー (過去 30 日間)
n=(360/Dth)+1
Trial>> for I=1:2:n R=12
w=(2*pi/5) Md=50 Theta=0 Thetarads= theta*pi/180
Id=(.5*Md*R^2)
Mp=75
Mb=30
alpha=0 u=.8 L=6*R theta=0 Dth=2 thetarads=theta*pi/180 rx=(R)*cos(theta)-L*cos(180)-L ry=(R*sin(theta))-(L*sin(180))-(R*sin(theta)) vx=(-R)*(w)*sin(theta) vy=(R)*(w)*cos(theta) alpha=0 ax=(-R)*alpha*sin(theta)-(R*(w^2)*cos(theta)) ay=(R)*alpha*cos(theta)-(R*w^2*sin(theta)) theta=theta+Dth end
  2 件のコメント
Chad Greene
Chad Greene 2016 年 6 月 11 日
What equations do you need to evaluate for each I? It's generally good to do as little as possible inside a loop. For example, you can evaluate Mp=75 just once before the loop rather than computing it every time.
A small note: It's much easier to read and run your code if you can format it using the {}Code button when posting a question.
Emily Gobreski
Emily Gobreski 2016 年 6 月 11 日
I am trying to evaluate ax,ay,rx,ry,and ax,ay. They all have theta values. I am trying to get the theta values to run from 0 to 360, testing values every 2 degrees. Thank you for the advice. i am new to this. I really appreciate your time.

サインインしてコメントする。

採用された回答

Chad Greene
Chad Greene 2016 年 6 月 11 日
Here's how you'd get ax and ay. First we define an array of values theta which go from 0 to 360 in steps of 2. Then we say for each value of theta, compute a corresponding value of ax and ay. I'm using k as a counter which goes through each index in theta.
R = 12;
w = 2*pi/5;
alpha = 0;
theta = 0:2:360;
for k = 1:length(theta)
ax(k)=(-R)*alpha*sind(theta(k))-(R*(w^2)*cosd(theta(k))) ;
ay(k)=(R)*alpha*cosd(theta(k))-(R*w^2*sind(theta(k))) ;
end
  2 件のコメント
Chad Greene
Chad Greene 2016 年 6 月 11 日
Here are the plotted results of ax and ay:
plot(ax,ay)
axis equal
Emily Gobreski
Emily Gobreski 2016 年 6 月 12 日
You are wonderful, thank you so much! i really appreciate it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by