フィルターのクリア

Plotting different datas on the same graph smoothly

1 回表示 (過去 30 日間)
Noi Sekuri
Noi Sekuri 2020 年 4 月 19 日
編集済み: darova 2020 年 4 月 19 日
I want to graph 3 functions (x,y1) (x,y2) (x,y3) smoothly on the same graph. How can I do that? It needs to be smooth. Here are my datas:
x = [1000, 2500, 5000, 7500, 10000, 25000, 50000, 75000, 100000, 250000, 500000, 750000, 1000000, 2500000, 5000000, 7500000, 10000000, 25000000, 50000000, 75000000, 100000000]
y1 = [1.1, 4.2, 9.5, 15.0, 20.0, 52.0, 109.0, 155.0, 208.0, 520.0, 1043.0, 1567.0, 2091.0, 5279.0, 10577.0, 15878.0, 21360.0, 56860.0, 120497.0, 194489.0, 272989.0]
y2 = [2.3, 13.0, 51.4, 3.0, 4.0, 5.0, 8.0, 12.0, 16.0, 39.0, 85.0, 138.0, 204.0, 779.0, 2442.0, 4944.0, 8381.0, 75829.0, 218749.0, 609079.0, 1130344.0]
y3 = [0.1, 0.3, 0.3, 1.0, 0.0, 1.0, 3.0, 5.0, 6.0, 14.0, 29.0, 37.0, 65.0, 147.0, 325.0, 407.0, 651.0, 3546.0, 4333.0, 5048.0, 10292.0]

回答 (2 件)

Mehmed Saad
Mehmed Saad 2020 年 4 月 19 日
x = [1000, 2500, 5000, 7500, 10000, 25000, 50000, 75000, 100000, 250000, 500000, 750000, 1000000, 2500000, 5000000, 7500000, 10000000, 25000000, 50000000, 75000000, 100000000];
y1 = [1.1, 4.2, 9.5, 15.0, 20.0, 52.0, 109.0, 155.0, 208.0, 520.0, 1043.0, 1567.0, 2091.0, 5279.0, 10577.0, 15878.0, 21360.0, 56860.0, 120497.0, 194489.0, 272989.0];
y2 = [2.3, 13.0, 51.4, 3.0, 4.0, 5.0, 8.0, 12.0, 16.0, 39.0, 85.0, 138.0, 204.0, 779.0, 2442.0, 4944.0, 8381.0, 75829.0, 218749.0, 609079.0, 1130344.0];
y3 = [0.1, 0.3, 0.3, 1.0, 0.0, 1.0, 3.0, 5.0, 6.0, 14.0, 29.0, 37.0, 65.0, 147.0, 325.0, 407.0, 651.0, 3546.0, 4333.0, 5048.0, 10292.0];
figure,plot(x,y1);
hold on,plot(x,y2);
hold on,plot(x,y3);
as you can see it is not smooth interpolate the data in order to make it smooth
xn =1000:1000:100000000;
y1_smooth = interp1(x,y1,xn,'pchip');
y2_smooth = interp1(x,y2,xn,'pchip');
y3_smooth = interp1(x,y3,xn,'pchip');
figure,plot(xn,y1_smooth);
hold on,plot(xn,y2_smooth);
hold on,plot(xn,y3_smooth);
Change interpolation method for good results

Karthi Ramachandran
Karthi Ramachandran 2020 年 4 月 19 日
What do you mean by smooth? If you want the data points to be connected
here it is .
x = [1000, 2500, 5000, 7500, 10000, 25000, 50000, 75000, 100000, 250000, 500000, 750000, 1000000, 2500000, 5000000, 7500000, 10000000, 25000000, 50000000, 75000000, 100000000];
y1 = [1.1, 4.2, 9.5, 15.0, 20.0, 52.0, 109.0, 155.0, 208.0, 520.0, 1043.0, 1567.0, 2091.0, 5279.0, 10577.0, 15878.0, 21360.0, 56860.0, 120497.0, 194489.0, 272989.0];
y2 = [2.3, 13.0, 51.4, 3.0, 4.0, 5.0, 8.0, 12.0, 16.0, 39.0, 85.0, 138.0, 204.0, 779.0, 2442.0, 4944.0, 8381.0, 75829.0, 218749.0, 609079.0, 1130344.0];
y3 = [0.1, 0.3, 0.3, 1.0, 0.0, 1.0, 3.0, 5.0, 6.0, 14.0, 29.0, 37.0, 65.0, 147.0, 325.0, 407.0, 651.0, 3546.0, 4333.0, 5048.0, 10292.0];
plot(x,y1,x,y2,x,y3)
Else if you dont want the edges(kind of discontinuities) , use interpolation one example is lagrange interpolation , see below file exchange , try it with x and y values

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by