# How do I plot the different elements of a matrix in a single plot?

5 views (last 30 days)
Sneh on 30 Jan 2023
Edited: Dyuman Joshi on 30 Jan 2023
I want to plot theta(1,1), theta(2,1), and theta(3,1). I tried to plot it but it just shows an empty graph.
for t = 0:1:100
omega1 = 0.02*cos(0.15*t) + 0.03*sin(0.15*t);
omega2 = 0.03*cos(0.15*t) - 0.02*sin(.15*t);
omega3 = 0.01;
omega = [omega1;omega2;omega3];
E = [pi/3;pi/5;pi/6];
C = [sin(E(3,1)) cos(E(3,1)) 0;
cos(E(3,1))*sin(E(2,1)) -sin(E(3,1))*sin(E(2,1)) 0;
-sin(E(3,1))*cos(E(2,1)) -cos(E(3,1))*cos(E(2,1)) sin(E(2,1)) ];
theta = (1/sin(E(2,1))) * C * omega;
end
Sneh on 30 Jan 2023
Sorry for the confusion, I want to plot each element of theta for every iteration on the same plot. I want to plot just theta with a line plot

Dyuman Joshi on 30 Jan 2023
Edited: Dyuman Joshi on 30 Jan 2023
for t = 0:1:100
omega1 = 0.02*cos(0.15*t) + 0.03*sin(0.15*t);
omega2 = 0.03*cos(0.15*t) - 0.02*sin(.15*t);
omega3 = 0.01;
omega = [omega1;omega2;omega3];
E = [pi/3;pi/5;pi/6];
C = [sin(E(3,1)) cos(E(3,1)) 0;
cos(E(3,1))*sin(E(2,1)) -sin(E(3,1))*sin(E(2,1)) 0;
-sin(E(3,1))*cos(E(2,1)) -cos(E(3,1))*cos(E(2,1)) sin(E(2,1)) ];
theta = (1/sin(E(2,1))) * C * omega;
plot(theta)
hold on
end There are three points in each curve, x values - [1;2;3], y values - [theta(1,1);theta(2,1);theta(3,1)]