How to create a loglog plot out of an array? I have a 2xn array of all my data points called points & my loglog plot is showing the same graph as the normal plot tool.

2 Ansichten (letzte 30 Tage)
%the data points match the equation y=x^2 almost exactly and my goal is to create
%the loglog plot with my attempted window. In theory the loglog plot should be a line
%with a slope of two... could be wrong though.
%Thank you!!
function
for i = 1:n
hold on
x=points(i,2);
y=points(i,1);
plot(x,y,'^','markers',2,'MarkerEdgeColor','b','MarkerFaceColor','y')
loglog(x,y,'^','markers',2,'MarkerEdgeColor','r','MarkerFaceColor','g')
xlim([.00001 1])
ylim([.00001 1])
end
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 1 Okt. 2017
Bearbeitet: Walter Roberson am 1 Okt. 2017
When you did the "hold on", you implicitly froze the log vs normal scale of the plot axes, so the loglog() will be treated the same as the plot().
Any one axes only has a single XScale and a single XScale. It is not possible for a single axes to display a plot in normal scale and log scale at the same time. You can use plotyy or the newer yyaxis calls to create two axes, one for each of the scales.
But you need to avoid using "hold on" before loglog() -- that or else you need to
set(gca, 'XScale', 'log', 'YScale', 'log')
which is what loglog() mostly does internally.

Weitere Antworten (0)

Kategorien

Mehr zu Two y-axis finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by