MATLAB: Can I plot semilogx, semilogy, loglog plots simultaneously by writing in code in a single m file

mfileplotting

I have the following code in an m file :
x = linspace(0,10);
y=x.^3;
semilogx(x,y);
semilogy(x,y);
loglog(x,y);
This gives the last plot only. How do I get the rest of the plots?

Best Answer

You could use figure to create three separate figures:
x = linspace(0,10);
y=x.^3;
figure()
semilogx(x,y);
figure()
semilogy(x,y);
figure()
loglog(x,y);
Or alternatively three subplots on one figure using subplot:
figure()
subplot(2,2,1)
semilogx(x,y);
subplot(2,2,2)
semilogy(x,y);
subplot(2,2,3)
loglog(x,y);
Related Question