Convert these lines to Curves

4 ビュー (過去 30 日間)
Maduka
Maduka 2022 年 12 月 23 日
コメント済み: Fabio Freschi 2022 年 12 月 23 日
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

回答 (1 件)

Fabio Freschi
Fabio Freschi 2022 年 12 月 23 日
編集済み: Fabio Freschi 2022 年 12 月 23 日
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 件のコメント
Maduka
Maduka 2022 年 12 月 23 日
Thanks, I appreciate, can I remove those markers?
Fabio Freschi
Fabio Freschi 2022 年 12 月 23 日
simply comment out the first plot

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by