using c++ in mATLAB

1 回表示 (過去 30 日間)
fatima hamad
fatima hamad 2020 年 4 月 15 日
回答済み: Ayush Gupta 2020 年 6 月 3 日
There is something wrong in script #2, The i values that must be save in the speeds array is [4 5 6 7 8 ] once five values are saved it must break, could someone help me please and figure what’s wrong with this code?
Also, I need to plot coefficient of static friction (y-axis) as a function of theta (x-axis) and each time at a angular velocity = speed [4 5 6 7 8 ] /r on the same plot, how to do this?
coefficient of static friction equation is eqn1.
and theta is provided.
  4 件のコメント
darova
darova 2020 年 4 月 15 日
And what is this for?
fatima hamad
fatima hamad 2020 年 4 月 15 日
Plot The coefficient of static friction versus theta for [0, 180] for different values (five values) of Ω > Ω???.
Ω??? = sqrt(g/r)
plot between coefficient of static friction in y-axis and theta for [0, 180] in x-axis for five angular velocity in the same plot.
coefficient of static friction in the given code is = x
This is the beginning of the code, can you please help in section two? thank you.
% Section 1 : To solve the two equations in term of cofficent of static
% friction & normal force.
% Variables naming:
% m: Mass of block A, kg.
% r: Radius of the drum, m.
% mu_s: Coefficient of static friction.
% N: Normal force, N.
% w = Angular velocity, rad/s.
% theta: Angular position, rad.
% g = Gravitational acceleration, m/s^2.
% x = mu_s
% y = N
clc
clear
syms theta w g m r x y
eqn1 = y-m*g*cos(theta)-m*r*w^2;
eqn2 = x*y-m*g*sin(theta);
[x,y] = solve(eqn1, eqn2)
% Section 2 : To plot coefficient of static friction vs theta for different angular speed
g = 9.81;
r = 0.7;
theta = (0:0.04:pi);
Angspeed = sqrt(g/r);

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

回答 (1 件)

Ayush Gupta
Ayush Gupta 2020 年 6 月 3 日
Try using with this code for section 2
g = 9.81;
r = 0.7;
theta = (0:0.04:pi);
speed = sqrt(g/r);
speeds = [0,0,0,0, 0];
noc = 1;
i =1 ;
while(noc <=5)
pause(1)
if speed < i
speeds(noc) = i;
noc = noc +1;
end
i = i+1;
end

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by