how to convert vector to scalar to get plot as line

4 views (last 30 days)
clear all;
clc;
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=27;
l2=23;
l3=19.8;
l4=5;
g=9.80665;
m1=23.687;
m2=17.15;
m3=2.0125;
m4=0.4179;
h1=765;
h2=568;
h3=418;
h4=220;
I1=0.099379;
I2=0.050526;
I4=0.000405;
I3=0.000702;
for x=0:0.1:10;
% z=0:0.1:10;
% qt1=x;
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;
qtt3=0.198*x;
qtt4=sin(x)+cos(x);
Q1=qtt2*((l1*l2*m2*cos(q2))/2 + l1*l2*m3*cos(q2)) - qt2*((l1*l2*m2*qt2*sin(q2))/2 + l1*l2*m3*qt2*sin(q2)) + qtt1*(2*I1 + (2*l1^2*m1)/3 + l1^2*m2 + l1^2*m3);
Q2=qtt2*(2*I2 + (l2^2*m2)/4 + l2^2*m3) + qtt1*((l1*l2*m2*cos(q2))/2 + l1*l2*m3*cos(q2)) - qt2*((l1*l2*m2*qt1*sin(q2))/2 + l1*l2*m3*qt1*sin(q2)) + (l1*l2*m2*qt1*qt2*sin(q2))/2 + l1*l2*m3*qt1*qt2*sin(q2);
Q3=g*m3*qtt3 - g*m4 - (g*m3)/2;
Q4=l4^2*m4*qtt4;
xa= l1* cos(Q1);
ya=l1* sin(Q);
plot(xa,ya)
xb=(l1+l2)* cos(Q2);
yb=(l1+l2) * sin(Q2);
plot(xb,yb)
xc=(l1+l2)* cos(Q3);
yc= qtt3*g* sin(Q3);
plot(xc,yc)
xd=(l1+l2+l4) * cos(Q4);
yd=(l1+l2+l4) * sin(Q4);
plot(xd,yd
hold on
end

Accepted Answer

Walter Roberson
Walter Roberson on 7 Dec 2016
You want to convert scalar to vector (like your tag), not vector to scalar (like your title)
See attached.
  2 Comments
Walter Roberson
Walter Roberson on 13 Dec 2016
You did not have a vector in your code, so there was no vector to convert into scalar.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 10 Sep 2017
Please stop editing away your question.
The people who answer questions here are volunteers. We answer questions so that everyone can learn from what we write. When you edit away your question, you leave us feeling as if you have taken advantage of us for some free private consulting.

Categories

Find more on Programming 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!