i got an error when i run this code ?

x=(1:100); for k=1:5 y(:,k)=k*log(x); end plot(x,y)
the error is in the third line? i want to make a single plot for different values of k

 Risposta accettata

Andrei Bobrov
Andrei Bobrov il 14 Mar 2013
Modificato: Andrei Bobrov il 14 Mar 2013
k = 1:5;
x = 1:100;
y = k'*log(x);
plot(x,y);

2 Commenti

you really got what i want but did you find the error in my code ??
see Wayne's answer

Accedi per commentare.

Più risposte (1)

Wayne King
Wayne King il 14 Mar 2013
Modificato: Wayne King il 14 Mar 2013
x=(1:100); for k=1:5 y(:,k)=k*log(x); end, plot(x,y)
You forgot a semicolon, or comma after end
or better yet:
x=(1:100);
for k=1:5
y(:,k)=k*log(x);
end
plot(x,y)

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by