How do I plot the different elements of a matrix in a single plot?
Show older comments
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
Jan
on 30 Jan 2023
Please show use the code for plotting. Most likely the problem is there, but unfortunately you did not post it.
Remember than plot(1,2) does not create a visible line, while plot(1,2, '.') draws a dot.
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
on 30 Jan 2023
Answers (1)
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 2-D and 3-D 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!