Subplots in Matlab 2017

Hi Everyone,
Having struggles with using subplot function. I tried learning from the very basics and tried out this simple code I found on internet
x = 0:5;
y = sin(x);
z = log(y);
subplot(2,2,1);
plot(x,y);
subplot(2,2,3);
plot(y,z);
subplot(2,2,4);
plot(x,z);
but this is giving me a index exceeds matrix dimensions error. What could be wrong?

Answers (1)

Walter Roberson
Walter Roberson on 12 Jul 2017
That code has problems with plotting imaginary values, but no problem with index exceeding matrix dimensions.
However, it is possible that you have previously made an assignment to a variable named "sin" or "log" or "subplot" or "plot"

Asked:

on 12 Jul 2017

Answered:

on 12 Jul 2017

Community Treasure Hunt

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

Start Hunting!