I have a small issue, how to link various nonlinear points within loop functions-for example y=0;
for k=1:10
y=k*2+k^3;
plot(y,k,'o-');
hold on;
end
hold off;
The Plot result is as follows. I want to connect all those points. I have little knowledge of interpolations (interp1).
is

 채택된 답변

KSSV
KSSV 2017년 6월 2일

2 개 추천

Don't put them in loop....calculate all y at once...
k=1:10 ;
y=k*2+k.^3;
plot(y,k,'o-');

댓글 수: 2

If you want to use loop...See the code...and you can learn few things in looping.
k = 1:10 ;
N = length(k) ;
y = zeros(N,1) ;
k = zeros(N,1) ;
figure
hold on
for i = 1:length(k)
k(i) = i ;
y(i)=i*2+i^3;
plot(y(i),k(i),'o-');
end
plot(y,k,'b')
KALYAN ACHARJYA
KALYAN ACHARJYA 2017년 6월 2일
편집: KALYAN ACHARJYA 2019년 3월 13일
My exact code is like this
for k=1:40 (k only for the number of iterations & must be used)
some operation
sp= output values in between 0 and 1
sn= output values in between 0 and 1
plot (sn,sp);
axis([0 1 0 1]);
hold on
end hold off;

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Exploration에 대해 자세히 알아보기

질문:

2017년 6월 2일

편집:

2019년 3월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by