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

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 comentarios

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.
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?
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

Iniciar sesión para comentar.

Respuestas (1)

Dyuman Joshi
Dyuman Joshi el 30 de En. de 2023
Editada: Dyuman Joshi el 30 de En. de 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)]

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de En. de 2023

Editada:

el 30 de En. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by