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

 Réponse acceptée

KSSV
KSSV le 2 Juin 2017

2 votes

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

2 commentaires

KSSV
KSSV le 2 Juin 2017
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 le 2 Juin 2017
Modifié(e) : KALYAN ACHARJYA le 13 Mar 2019
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;

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Exploration dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by