how to unite two curves smoothly in matlab?

22 visualizaciones (últimos 30 días)
Zeynep Ertekin
Zeynep Ertekin el 4 de Abr. de 2022
Comentada: Zeynep Ertekin el 4 de Abr. de 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]);

Respuesta aceptada

Davide Masiello
Davide Masiello el 4 de Abr. de 2022
Editada: Davide Masiello el 4 de Abr. de 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 comentarios
Star Strider
Star Strider el 4 de Abr. de 2022
@Zeynep Ertekin — Since the answer worked, it is appropriate to Accept it.
Zeynep Ertekin
Zeynep Ertekin el 4 de Abr. de 2022
Hey! I didn't know that I should have accepted it, thanks a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Preprocessing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by