Non-existing values in the Plot
Mostrar comentarios más antiguos
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.
Code
function graph
clc;
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 on
end
This is what my code generates:

This is what excel draws (and what it should be):

Any ideas?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!