Greetings. I'm having trouble with some code. This function should display a curve based on X and Y values loaded from a .txt file. For some reason, when it displays the curve it also draws a line in the Y axis. At first I thought I had a problem with the .txt, but i tried plotting it in excel and the curve appears as it should. Also, this does not happen with all the .txt files I'm working with.
function graphclc;set(0,'DefaultFigureColor','w',...'DefaultAxesColor','w',...'DefaultAxesXColor','k',...'DefaultAxesYColor','k',...'DefaultAxesZColor','k',...'DefaultTextColor','k',...'DefaultLineColor','k');x = load('try.txt');r1 = load('try.txt');r1 = r1(:,2);f1=figure(1);clf;get(f1);set(f1,'Units','centimeters','Position',[3 3 24 14]);axes1 = axes('Parent',f1,'FontWeight','bold','FontSize',14,'Ygrid', 'on','grid', ':','Position',[0.15 0.2 0.8 0.7]);set(gcf,'Color',[1,1,1]);box on;hold on;axis([0, 16, 0, 6e+06]);plot(x, r1, '-g','LineWidth',2,'Marker','none', 'Markersize', 5);hold onend
This is what my code generates:
This is what excel draws (and what it should be):