MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by mohamed
on 14 Mar 2013

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

*No products are associated with this question.*

Answer by Andrei Bobrov
on 14 Mar 2013

Edited by Andrei Bobrov
on 14 Mar 2013

Accepted answer

k = 1:5; x = 1:100;

y = k'*log(x); plot(x,y);

Answer by Wayne King
on 14 Mar 2013

Edited by Wayne King
on 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)

## 0 Comments