Convert these lines to Curves

3 vues (au cours des 30 derniers jours)
Maduka
Maduka le 23 Déc 2022
Commenté : Fabio Freschi le 23 Déc 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

Réponses (1)

Fabio Freschi
Fabio Freschi le 23 Déc 2022
Modifié(e) : Fabio Freschi le 23 Déc 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 commentaires
Maduka
Maduka le 23 Déc 2022
Thanks, I appreciate, can I remove those markers?
Fabio Freschi
Fabio Freschi le 23 Déc 2022
simply comment out the first plot

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by