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 CenterFile Exchange에서 Data Preprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by