Help changing axis direction with for loop plot.
5 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to graph data from excel with a for loop but I need to reverse and log my x axis. I figured out how to log the axis but trying to use set(gca,''XDir','reverse') does not work. It gives the error "Unable to use a value of type matlab.graphics.axis.Axes as an index.". Thanks for any advice. Here is also an example of what I'm looking to achieve as far as the axis is concerned.
data = xlsread('Field_Testing','GrainSize');
sz = size(data);
rows = sz(1);
colms = sz(2);
set1 = data(:,[1,2]);
c = {};
for j = 1:colms
if rem(j,2) == 0
set = data(:, [j-1, j]);
c{end+1} = set; %saves to end of each previous cell
end
end
figure()
for z = 1:(colms/2)
arr = c{z};
arr = rmmissing(arr);
x = arr(:,1);
y = arr(:,2);
p = semilogx(x,y);
set(gca,'XDir','reverse')
hold on
end
hold off

3 个评论
Les Beckham
2020-4-11
I'm glad that helped. As far as doing the 'reverse' log, you might try my idea of plotting 1/x instead of x and experiment to see if that gets you closer to what you want.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!