I'd like to plot mutiple values onto the same graph with a logarithmic Y scale. The following code plots the values onto a linear scale graph and works, however trying to change 'plot' with 'semilogy' outputs a blank graph.
hold on;
for i = 1:10
[val1(i), val2, val3, val4] = myFunct(i, fileName);
end;
plot(val1);
hold off;
What do I need to change to create a Y scale that is logarithmic?
Edited code:
hold on;
for i = 1:10
[val1(i), val2, val3, val4] = myFunct(i, fileName);
end;
val1(1) = 0.000001; %index 1 is always zero, index 2 may or may not be zero
val1(2) = 0.000001;
semilogy(val1);
hold off;
Output of the above code:
The hold on
command prevents the figure from being updated from the regular plot
you did before to semilogy
. To solve this you should close your figure and run the code again.
Note that there is no reason to use hold
commands if you only have one plotting command. The purpose of hold
is to enable several plotting commands to be overlayed in the same figure.