how to unite two curves smoothly in matlab?

8 ビュー (過去 30 日間)
Zeynep Ertekin
Zeynep Ertekin 2022 年 4 月 4 日
コメント済み: Zeynep Ertekin 2022 年 4 月 4 日
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]);

採用された回答

Davide Masiello
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 件のコメント
Star Strider
Star Strider 2022 年 4 月 4 日
@Zeynep Ertekin — Since the answer worked, it is appropriate to Accept it.
Zeynep Ertekin
Zeynep Ertekin 2022 年 4 月 4 日
Hey! I didn't know that I should have accepted it, thanks a lot!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by