how to unite two curves smoothly in matlab?

22 vues (au cours des 30 derniers jours)
Zeynep Ertekin
Zeynep Ertekin le 4 Avr 2022
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]);

Réponse acceptée

Davide Masiello
Davide Masiello le 4 Avr 2022
Modifié(e) : Davide Masiello le 4 Avr 2022
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 commentaires
Star Strider
Star Strider le 4 Avr 2022
@Zeynep Ertekin — Since the answer worked, it is appropriate to Accept it.
Zeynep Ertekin
Zeynep Ertekin le 4 Avr 2022
Hey! I didn't know that I should have accepted it, thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Preprocessing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by