Borrar filtros
Borrar filtros

Convert these lines to Curves

1 visualización (últimos 30 días)
Maduka
Maduka el 23 de Dic. de 2022
Comentada: Fabio Freschi el 23 de Dic. de 2022
N = [5:5:10 20:30:80];
t = (0:0.2:1).';
U = [0 0 0 0 0;
-0.203 -0.2045 -0.2094 -0.2248 -0.2411;
-0.8334 -0.8742 -0.9593 -1.2573 -1.6266;
-1.9722 -2.1899 -2.6840 -4.737 -7.9306;
-3.7592 -4.51 -6.3789 -16.1119 -35.5583;
-6.4136 -8.4597 -14.1636 -52.4222 -148.671];
hp = plot(t,U,'-');
lstr = cell(numel(N),1);
title('Effect of Radiation on Velocity')
for k = 1:numel(N)
lstr{k} = sprintf('N = %d',N(k));
end
legend(hp,lstr,'location','southwest')
Please I need assistance in converting the lines to curves

Respuestas (1)

Fabio Freschi
Fabio Freschi el 23 de Dic. de 2022
Editada: Fabio Freschi el 23 de Dic. de 2022
You can interpolate your data using interp1.
Warning: the interpolation may be not accurate for your trend, in this case is only an "educated guess".
clear variables, close all
N = [5:5:10 20:30:80];
t = (0:0.2:1).';
U = [0 0 0 0 0;
-0.203 -0.2045 -0.2094 -0.2248 -0.2411;
-0.8334 -0.8742 -0.9593 -1.2573 -1.6266;
-1.9722 -2.1899 -2.6840 -4.737 -7.9306;
-3.7592 -4.51 -6.3789 -16.1119 -35.5583;
-6.4136 -8.4597 -14.1636 -52.4222 -148.671];
figure, hold on
hp = plot(t,U,'o');
title('Effect of Radiation on Velocity')
% use a finer sampling of t vector
tint = (0:0.02:1);
% interpolate
Uint = interp1(t,U,tint,'pchip');
% restart color order
set(gca,'ColorOrderIndex',1);
% plot
hp = plot(tint,Uint,'-');
% legend
lstr = arrayfun(@(x)['N = ',num2str(x)],N,'UniformOutput',false);
legend(hp,lstr,'location','southwest')
  2 comentarios
Maduka
Maduka el 23 de Dic. de 2022
Thanks, I appreciate, can I remove those markers?
Fabio Freschi
Fabio Freschi el 23 de Dic. de 2022
simply comment out the first plot

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by