how to plot a continuous graph in a loop

16 visualizaciones (últimos 30 días)
Sukhversha Luthra
Sukhversha Luthra el 29 de En. de 2018
Comentada: Sukhversha Luthra el 30 de Nov. de 2021
for k=1:10;
x=5;
y=2*x-5*k*k*k
plot(k,y,'*');
hold on;
end
This program gives me a dotted graph.
however I wanted to get a regular(continuous) graph.
Please help me to find suitable command for that.

Respuesta aceptada

VBBV
VBBV el 28 de Nov. de 2021
for k=1:10;
x=5;
y(k)=2*x-5*k*k*k;
plot(1:k,y(1:k),'*'); % use the loop indices to plot in a loop
end
you can use the loop indices to plot the graph inside the loop

Más respuestas (1)

Morteza Hajitabar Firuzjaei
Morteza Hajitabar Firuzjaei el 29 de En. de 2018
you can make your vectors and plot your graph, like:
s = [1 1 1 1];
t = [2 4 5 3];
G = graph(s,t);
plot(G);
Mortrza Hajitabar Firuzjaei
  1 comentario
Sukhversha Luthra
Sukhversha Luthra el 30 de En. de 2018
but I need to get a graph for a loop in which k is known but 'y', that depends on 'k', gets its values in the loop itself

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by