Clear Filters
Clear Filters

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

1 view (last 30 days)
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
  3 Comments
Dyuman Joshi
Dyuman Joshi on 30 Jan 2023
Please clarify if you want to plot the final theta or plot theta for every iteration, all in a single graph.
And are you plotting theta against anything or just theta?
Do you want a line plot or just dots?
Sneh
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

Sign in to comment.

Answers (1)

Dyuman Joshi
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)]

Categories

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