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 CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by