Convert these lines to Curves
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
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
Ver también
Categorías
Más información sobre Interpolation 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!