How can I smoothen my plots by removing sharp edges/points in the plots?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Comfort Sekga
el 12 de Oct. de 2024
Comentada: Star Strider
el 12 de Oct. de 2024
I have two codes for generating plots given below. The first code generate a plot from the data file attached. I need help to remove sharp edges/points that appear on the plots so that I get smooth curves. Below is the first code;
A=load('dataQ0.05t.txt');
y = A(:,2);
x = A(:,1);
plot(x,y,'b')
semilogx(x,y,'b')
The second code;
r = linspace(10^-2,10^2);
eta=zeros(size(r));
%hold on;
for delta= [0 1 2 3 4 5 6]
for k=1:numel(r)
f=@(x,y) (1./pi).*(x.*exp(-3.44.*r(k).^(5/3).*x.*(sin(y/2)).^(5/3)).*cos(delta*y));
eta(k) = integral2(f,0,1,0,2*pi).*exp(-10);
% hold on
end
plot(r,eta)
axis([10^(-0.5) 10^2 10.^(-9) 10.^(-4)])
loglog(r,eta)
hold on
end
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Oct. de 2024
Editada: Star Strider
el 12 de Oct. de 2024
One option is to use vectors with increased resolutiuon (numbers of points), and then interpolate as necessary —
A=load('dataQ0.05t.txt');
y = A(:,2);
x = A(:,1);
plot(x,y,'b')
semilogx(x,y,'b')
xi = linspace(min(x), max(x), 250).';
yi = interp1(x, y, xi);
figure
semilogx(xi, yi, 'b')
title('Increased Resolution, Interpolated')
% r = linspace(10^-2,10^2);
r = logspace(-2, 2, 100);
eta=zeros(size(r));
%hold on;
for delta= [0 1 2 3 4 5 6]
for k=1:numel(r)
f=@(x,y) (1./pi).*(x.*exp(-3.44.*r(k).^(5/3).*x.*(sin(y/2)).^(5/3)).*cos(delta*y));
eta(k) = integral2(f,0,1,0,2*pi).*exp(-10);
% hold on
end
plot(r,eta)
axis([10^(-0.5) 10^2 10.^(-9) 10.^(-4)])
loglog(r,eta)
hold on
end
title('Using ‘logspace’ With Increased Resolution')
.
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!