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.

 채택된 답변

VBBV
VBBV 2021년 11월 28일

0 개 추천

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

추가 답변 (1개)

Morteza Hajitabar Firuzjaei
Morteza Hajitabar Firuzjaei 2018년 1월 29일

0 개 추천

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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

질문:

2018년 1월 29일

댓글:

2021년 11월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by