how to unite two curves smoothly in matlab?
22 次查看(过去 30 天)
显示 更早的评论
Hello,
I have two distinct curves, sharing one data point in common. I would like to join/unite these curves in a plot, without repeating the same data point. Additionally, I want to get rid of the spike @ 15.2 Here is the excel that I read the data from, and the fig output. If anyone would help me please??
In the excel;
Column A and B shows the data of the first curve, x and y respectively.
Column D and E shows the data of the second curve, x and y respectively.
Column G and H shows the united data, x and y data. On the rows of 1001 and 1002, data at 15.2 is repeated. Even tough I eliminate one row, I do not know how to smooth the region of 15.2. Hope there is a smarter way than deleting some points and interpolating with new ones.
Your helps would be more than apprecitated..
clc
clear all
close all
Ku_eGR_IL_WG_S21=xlsread('Ku_eGR_IL_WG.xlsx','H:H'); % A S21 magnitude
frequency=xlsread('Ku_eGR_IL_WG.xlsx','G:G'); % frequency
plot(frequency,Ku_eGR_IL_WG_S21,'LineWidth',2);
grid on
grid minor
xlabel('Frequency (GHz)');
ylabel('Insertion S21 (dB)');
title(' Ku eGR IL WG ');
legend('eGR IL');
set(gca,'FontSize',15,'fontweight','bold')
xlim([12 18.4]);
0 个评论
采纳的回答
Davide Masiello
2022-4-4
编辑:Davide Masiello
2022-4-4
This should work
clc, clear, clf
Ku_eGR_IL_WG_S21 =xlsread('Ku_eGR_IL_WG.xlsx','H:H'); % A S21 magnitude
frequency =xlsread('Ku_eGR_IL_WG.xlsx','G:G'); % frequency
[frequency,idx,idx2] = unique(frequency);
Ku_eGR_IL_WG_S21 = Ku_eGR_IL_WG_S21(idx);
jump = Ku_eGR_IL_WG_S21(find(~diff(idx2)))-Ku_eGR_IL_WG_S21(find(~diff(idx2))+1);
Ku_eGR_IL_WG_S21(find(~diff(idx2))+1:end) = jump+Ku_eGR_IL_WG_S21(find(~diff(idx2))+1:end);
plot(frequency,Ku_eGR_IL_WG_S21,'LineWidth',2);
grid on
grid minor
xlabel('Frequency (GHz)');
ylabel('Insertion S21 (dB)');
title(' Ku eGR IL WG ');
legend('eGR IL');
set(gca,'FontSize',15,'fontweight','bold')
xlim([12 18.4]);
9 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!