- Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
- Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
- Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support so we can investigate.
can any one correct this code please?
2 views (last 30 days)
Show older comments
MUHAMMAD UBAID KHALID
on 10 Mar 2023
Answered: Cris LaPierre
on 10 Mar 2023
% CRANK CONNECTING ROD EXPERIMENT
clc
clear all
close all
L=4; %no of links
Jl=4; %no of full joints
J2=0; %no of half jonts
M=3*(L-1)-2*Jl-J2;
l1=50; %lenght of input crank in mm
12=180; %lenght of link2 in mm
14=165; %lenght of link3 in mm
D1=0:15:360; %angle of input link
wl=15; %angular velocity of input link in degree/sec
i=0;
for i=l:1:25
D2(i)=atan((ll*sind(D1(i)))/((ll*sind(D1(i)))-14))+180; %angle of link 2
13(i)=((((ll*cosd(D1(i)))-14)/cosd(D2(i)))-12)+150;%lenght of link 3
V3(i)= (-ll*sind(D1(i))*wl);%veloity of link 3
a3(i)=-ll*wl*wl*cosd(D1(i));%accelartaion of link 3
end
subplot(2,2,1)
plot(01,13)
xlabel( 'theeta 01')
ylabel('lenght 13')
title('Theeta VS Lenght')
subplot(2,2,2)
plot(01,V3)
xlabel('theeta 01')
ylabel('velocity V3')
title('Theeta VS velocity')
subplot(2,2,3)
plot(01,a3)
xlabel('theeta 01')
ylabel('acceleration a3')
title('Theeta VS accelartion')
2 Comments
John D'Errico
on 10 Mar 2023
Why? What do YOU think is wrong with it? Code is just code, without any understanding of what it should be doing. As such, that code is perfect. It does exactly what it should do. Remember, we cannot read your mind.
Is there an error? If so, what error? Show the complete error message, so EVERYTHING IN RED.
Accepted Answer
Cris LaPierre
on 10 Mar 2023
Did you happen to use OCR to capture this code? I converted your text to code and ran it. From there, it appears the error is you use the number 1 to start several of your variable names instead of, what I'm guessing is supposed to be a lowercase 'l'.
It looks like the same thing has happened with your angles - They are defined as 'D1' but then in your plotting code you use '01'.
% CRANK CONNECTING ROD EXPERIMENT
clc
clear all
close all
L=4; %no of links
Jl=4; %no of full joints
J2=0; %no of half jonts
M=3*(L-1)-2*Jl-J2;
l1=50; %lenght of input crank in mm
l2=180; %lenght of link2 in mm
l4=165; %lenght of link3 in mm
D1=0:15:360; %angle of input link
wl=15; %angular velocity of input link in degree/sec
i=0;
for i=1:1:25
D2(i)=atan((l1*sind(D1(i)))/((l1*sind(D1(i)))-14))+180; %angle of link 2
l3(i)=((((l1*cosd(D1(i)))-14)/cosd(D2(i)))-12)+150;%lenght of link 3
V3(i)= (-l1*sind(D1(i))*wl);%veloity of link 3
a3(i)=-l1*wl*wl*cosd(D1(i));%accelartaion of link 3
end
subplot(2,2,1)
plot(D1,l3)
xlabel( 'theeta D1')
ylabel('lenght l3')
title('Theeta VS Lenght')
subplot(2,2,2)
plot(D1,V3)
xlabel('theeta D1')
ylabel('velocity V3')
title('Theeta VS velocity')
subplot(2,2,3)
plot(D1,a3)
xlabel('theeta D1')
ylabel('acceleration a3')
title('Theeta VS accelartion')
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!