the graph is empty, how can i solve this,(there are lot of constant values)

1 view (last 30 days)
clc;
clear all;
close all;
syms q1 q2 q3 q4 qt1 qt2 qt3 qt4 m1 m2 m3 m4 l1 l2 l3 l4 h1 h2 h3 h4 g x
syms I1 I2 I3 I4 Q1 Q2 Q3 Q4 qtt1 qtt2 qtt3 qtt4 t real
l1=270*10^-3;
l2=230*10^-3;
l3=198*10^-3;
l4=50*10^-3;
g=9.80665;
m1=23.687;
m2=17.15;
m3=2.0125;
m4=0.4179;
h1=765*10^-3;
h2=568*10^-3;
h3=418*10^-3;
h4=220*10^-3;
I1=0.099379;
I2=0.050526;
I4=0.000405;
I3=0.000702;
k1=(1/3)*(m1*l1^2*qt1^2);
k2=0.5*m2*((qt1^2*l1^2)+(0.25*qt2^2*l2^2)+(qt1*qt2*l1*l2*cos(q2)))+(0.5*I2*qt1);
k3=0.5*m3*((qt1^2*l1^2)+(qt3^2*l2^2)+(2*qt1*qt3*l1*l2*((qt1^2)+(qt1*qt2))*cos(q2)))+(0.5*I1*qt1^2)+(0.5*I2*(qt1+qt2)^2);
k4=(0.5*m4*l4^2*qt4^2);
p1=m1*g*h1;
p2=m2*g*(h1-h2);
p3=m3*g*(h1-h2-(0.5*q3));
p4=m4*g*(h1-h2-q3-(h4*0.5));
k=k1+k2+k3+k4;
p=p1+p2+p3+p4;
L=k-p;
for x=0:1:10
q1=3-(3*cos(pi*x/10));
qt1=3*sin(pi*x/10)*pi/10;
qtt1=3*cos(pi*x/10)*(pi^2/100);
q2=3-(3*sin(pi*x/10));
qt2= -3*cos(pi*x/10)*(pi/10);
qtt2=3*sin(pi*x/10)*(pi^2/100);
qt3=0.198*x^2;
qtt3=0.198*x;
qtt4=sin(x)+cos(x);
Lqt1 =I2/2 + I1*qt1 + (m2*(2*qt1*l1^2 + l2*qt2*cos(q2)*l1))/2 + (m3*(2*l1^2*qt1 + 2*l1*l2*qt3*cos(q2)*(qt1^2 + qt2*qt1) + 2*l1*l2*qt1*qt3*cos(q2)*(2*q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2*m3*qt1*qt2*sin(q2)*(qt1^2 + qt2*qt1);
Ldt4 =l4^2*m4*qtt4;
Q1 = Ldt1 - Lq1
% Q2 = Ldt2 - Lq2
% Q3 = Ldt3 - Lq3
% Q4 = Ldt4 - Lq4
plot(x,Q1)
hold on
end
  4 Comments
Walter Roberson
Walter Roberson on 7 Sep 2016
Well, we aren't going to be able to help you further without a copy of your code.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 7 Sep 2016
You are using plot() with scalar x and scalar Q1, rather than vectors, so you are drawing a bunch of points, not a line. The default for plot() is to use no marker, so the points you draw are all invisible. You need to add a marker specification to the plot() call, or else you need to record the x values and the Q1 values as you go through the loop instead of plotting, then after the loop plot() them all at one time to get a line.

Tags

Community Treasure Hunt

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

Start Hunting!