How would I go about using for loops to create subplots of a function while also changing the value of a constant for each subplot?
I'm going to simplify my equations in the example.
Say I want to create 3 subplots of the function y=a*x. The values of a are 2, 4, and 6. In subplot 1 I want to plot y=2x, in subplot 2 I want to plot y=4x, and in subplot 3 I want to plot y=6x. The values of x are 1:10.
I tried the following:
x = [0:1:10];for i=1:3 subplot(1,3,i) for a=[2 4 6]; y=a*x; plot(x,y) end end
But that just gave me 3 identical plots for y=6x.
Best Answer